YouTip LogoYouTip

Asp Ref Session

# ASP Session Object * * * The Session object is used to store information about a user session, or to change settings for a user session. * * * ![Image 2: Examples](#) ## Try it - Examples (#) This example demonstrates the "LCID" property. This property sets or returns an integer indicating a location or region. Content such as dates, times, and currencies is displayed according to the location or region. (#) This example demonstrates the "SessionID" property. This property returns a unique id for each user. This id is generated by the server. (#) This example demonstrates the "Timeout" property. This property sets or returns the timeout period for a session (in minutes). * * * ## Session Object When you work with an application on your computer, you open it, make some changes, and then close it. This is much like a Session. The computer knows who you are. It knows when you opened the application and when you closed it. However, on the internet, a problem arises: because HTTP addresses cannot maintain state, the web server does not know who you are or what you did. ASP solves this problem by creating a unique cookie for each user. The cookie is sent to the user's computer and contains information that identifies the user. This interface is called the Session object. The Session object is used to store information about a user session, or to change settings for a user session. Variables stored in the Session object hold information about a single user and are available to all pages in the application. Common information stored in session variables includes name, id, and parameters. The server creates a new Session for each new user and destroys the Session object when it expires. The collections, properties, methods, and events of the Session object are described below: ### Collections | Collection | Description | | :--- | :--- | | (#) | Contains all items added to the session via scripting commands. | | (#) | Contains all objects added to the session using the HTML <object> tag. | ### Properties | Property | Description | | :--- | :--- | | (#) | Specifies the character set used to display dynamic content. | | (#) | Sets or returns an integer indicating a location or region. Content such as dates, times, and currencies is displayed according to the location or region. | | (#) | Returns a unique id for each user. This id is generated by the server. | | (#) | Sets or returns the timeout period for the Session object in the application (in minutes). | ### Methods | Method | Description | | :--- | :--- | | (#) | Destroys a user's session. | | [Contents.Remove](#) | Removes an item from the Contents collection. | | [Contents.RemoveAll()](#) | Removes all items from the Contents collection. | ### Events | Event | Description | | :--- | :--- | | (#) | This event occurs when a session ends. | | (#) | This event occurs when a session starts. |
← Ng Ng MouseleaveAsp Ref Application β†’