ASP Session Object

The Session object stores information needed for a particular user’s session on the web server. It is automatically created every time when an ASP page from the web site or web application is requested by a user who does not already have a session, and it remains available until the session expires.

The Session object is user specific. It can be used to store variables specific to a particular user and IIS will maintain these variables when the client moves across pages within your web site.

The Session object is based on using cookies, so if cookies are not permitted on the client browser (because of firewall issues, browser incompatibility, or desktop/network security concerns), the Session object is rendered useless. The syntax, collections, properties, methods and events of the ASP Session object are as follows:

Syntax

Session.collection|property|method

Collections

Collections Description
Contents The Contents collection contains all the items added to the session through the use of scripts (not through the use of the <OBJECT> tag). The collection can be used to determine the value of a specific item, or to iterate over all the items in the session.
StaticObjects The StaticObjects collection contains all of the objects with session-level scope created through the use of the <OBJECT> tag. The collection can be used to retrieve properties of a specific object in the collection, or to use a specific method of a given object in the collection.

Properties

Properties Description
CodePage The CodePage property defines the code page that will be used to display the page content in the browser. A code page is a character set containing all the alphanumeric characters and punctuation used by a specific locale.
LCID The LCID property is used to set or get the locale identifier (LCID) of the page is sent to the browser. The local identifier is used to control how dates, times and currencies will be displayed according to the specific location or region.
SessionID The SessionID is a read-only property that uniquely identifies each current user’s session. Each session has a unique identifier that is generated by the server when the session is created and stored as a cookie on the client machine.
TimeOut The Timeout property sets or returns the timeout period (in minutes) for thе Session object in this application. If the user does not refresh or request a page within the timeout period, the session ends. Can be changed in individual pages as required.

Methods

Methods Description
Abandon The Abandon method is used to destroy all objects stored in a Session object and releases their resources. If the Abandon method is not explicitly called, the web server will maintain all session information until the session times out.
Contents.Remove The Contents.Remove method removes the specified item from the Session object Contents collection.
Contents.RemoveAll The Contents.RemoveAll method removes all the items from the Session object Contents collection.

Events

Events Description
Session_OnStart The Application_OnStart event occurs when a new session starts, before the page that the user requests is executed.
Session_OnEnd The Session_OnEnd event occurs when the user’s session is abandoned or times out.
admin

admin

Leave a Reply

Your email address will not be published.