筆者提供下列程式可供設定:
於Web.config中 設定:
<sessionState cookieless="false" customprovider="MyCustomMadeSessionProvider" mode="Custom" regenerateexpiredsessionid="true"> <providers> <add autogenerateschema="True" connectionstringname="MyStateconnectionStringName" description="my custom state provider" enableexpirecallback="False" name="MyCustomMadeSessionProvider" type="web.sessionstate.MySessionStateConfig" writeexceptionstoeventlog="False"> </add></providers> </sessionState>
並在connectionStrings區塊中加入(紅字請換成自行的設定)
<connectionStrings> <add name="MyStateconnectionStringName" connectionString="Data Source=localhost;Initial Catalog=dbName;Persist Security Info=True;User ID=ID;Password=PWD;" /> </connectionStrings>MySessionStateConfig程式下載
需建立的table
CREATE TABLE sessions (
SessionId varchar(80) NOT NULL,
ApplicationName varchar(255) NOT NULL,
Created datetime NOT NULL,
Expires datetime NOT NULL,
LockDate datetime NOT NULL,
LockId int(10) unsigned NOT NULL,
Timeout int(10) unsigned NOT NULL,
Locked smallint(1) unsigned NOT NULL,
SessionItems longtext NOT NULL,
Flags int(10) unsigned NOT NULL,
PRIMARY KEY ( SessionId , ApplicationName )
) ENGINE=InnoDB DEFAULT CHARSET=utf8
沒有留言:
張貼留言