To |
Do This |
Access the current client's session state |
Use the Page.Session property Use the current context's HttpContext.Session property |
Access a specific value in the current client's session state |
Session state is a set of key-value pairs. Access the data with the string key originally used to insert the data in the cache |
Store session state in-proc |
Set the <SessionState> attributes in Web.Config. Set mode to InProc |
Store session state in a state server |
Set the <SessionState> attributes in Web.Config. Set mode to StateServer. Be sure to include a stateConnection string |
Store session state in SQL Server |
Set the <SessionState> attributes in Web.Config. Set mode to SQLServer. Be sure to include a sqlConnection string |
Disable session state |
Set the <SessionState> attributes in Web.Config. Set mode to Off |
Use cookies to track session state |
Set the <SessionState> attributes in Web.Config. Set cookieless to false |
Use URL to track session state |
Set the <SessionState> attributes in Web.Config. Set cookieless to true |
Set session state timeout |
Set the <SessionState> attributes in Web.Config. Set timeout to a value (representing minutes) |