Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




how to save session in sql server - SqlSessionStateStore

SqlSessionStateStore: Follow below steps:
 
To add session in sql server.
Open website (in visual studio)
Open web.config
 
Mention the session mode and provide the credentials.

<system.web>
<sessionStatemode="SQLServer"sqlConnectionString="Server=server name;uid=sa;pwd=password;Initial Catalog=database name"timeout="20"allowCustomSqlDatabase="true"></sessionState>

</ system.web >

allowCustomSqlDatabase = " true " should be true when you enter the database name where the session will be saved.
 
Session will be added in following tables
.
  • ASPStateTempApplications
  • ASPStateTempSessions



If there are 20 instances of session of website is open then there will be 20 rows will be in ASPStateTempSessions
 
Columns Descriptions of Table ASPStateTempSessions
SessionId- unique session id assigned to instance
Created- When the instance of that session id is created
Expires - when the session will be expire. Like if session time out in web.config is 20 Mins. and in table in Created Colum the value is "2011-05-15 10:55:57.950" then the value in expires will be "2011-05-15 11:16:01.920" (20 mins after the creation time)
LockDate  UTC date and time session was locked
LockDateLocal Local date and time session was locked
LockCookie Lock ID
Timeout Session timeout in minutes
Locked 1=Session locked, 0=Session not locked
SessionItemShort Serialized session state (if <= 7,000 bytes)
SessionItemLong Serialized session state (if > 7,000 bytes) it is of Image Type
Flags Session state flags (0=initialized session, 1=Uninitialized session)
 
Columns Descriptions of Table ASPStateTempApplications Schema
AppId - Unique ID
AppName - Website name and root information
 

Helpful Website Url
http://msdn.microsoft.com/en-us/library/aa478952.aspx
Share this article   |    Print    |    Article read by 5510 times
Author:
Rohit kakria
I am software developer, moderator of xpode.com
Related Articles: No related article
Related Interview Questions: No related interview question