The Session object stores information that is needed for a particular user session. Variables stored in the Session object are not discarded when the user browses between pages in the Web application. Instead, these variables persist for the entire user session. The Session object differs from a cookie in that the Session object is maintained on the server instead of on the user's computer.
The Web server automatically creates a Session object when a session starts. When the session expires or is abandoned , the Web server destroys the Session object.
A session starts when a user first requests an ASP file from the virtual directory of your Web application. When the session starts, the Web application generates a SessionID and sends a response to the browser to create a cookie for the SessionID . The SessionID cookie is sent to a browser, but is not stored on the user's hard disk. Instead, the SessionID cookie is maintained in the memory of the user's computer.
If a user does not accept the SessionID cookie, the Session object will not be supported for that user.
By default, a session lasts 20 minutes. You can change this default setting by modifying the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\ASP\Parameter s\SessionTimeout
The Session object has two properties and one method.
The SessionID property determines the session identification for a user, and the Timeout property sets the timeout period for a session.
The Abandon method destroys a Session object and releases its resources.
Syntax
Use the following syntax to set properties and methods for the Session object:Session. propertymethod
Example
This example creates and stores the nickname and hometown values of a user:<% Session("nickname") = "Nancy" Session("hometown") = "Redmond %>
Example
This example shows how to use the information stored in the Session object:Hello <%= Session("nickname") %>.<BR> How is the weather in <%= Session("hometown") %>?<BR>