I. Overview of the Session object
The session object actually refers to a collection of global variables that the server side allocates to the user, which can be auto-generated or defined by the programmer on server-side scripts, from the time the user reaches the site to the point of departure.
When a user jumps between Web pages in an application, the variables stored in the session object will not be lost and will continue throughout the user's sessions.
When a user requests a page of an ASP application, if the user has not yet established a Session object, the server automatically creates a Session object and specifies a unique session ID, which only allows the owner of the session ID to be used, and the different user's Se Ssion stores their specific information, such as user name, gender, browser type, display resolution, access time, etc., which will benefit the server to authenticate the user identity, so as to achieve Web page personalization.
There are two ways to end a Session object: One is an implicit method and the other is an explicit method. The implicit method is that when the user accesses the WEB server at intervals exceeding the time limit set by the session object's TimeOut property, the Session object ends automatically, and the explicit method terminates it using the Abadon method of the Session object. When the session is finished, the variables of the sessions object are also freed and their values are no longer available.
The syntax format for the session object is as follows:
Session.集合| 属性 | 方法
Second, the session object properties, such as table one:
Property |
Meaning |
CodePage |
The code page that will be used for symbolic mapping, and determines which code page will be displayed for dynamic content. |
Lcid |
Returns the field identity, which determines the location identification used to display dynamic content. |
SessionID |
Returns the user's session identity. When you create a session, the server generates a separate identity for each session. |
Timeeout |
The time-out period for application session state, in minutes. |
Third, the Session object collection, as table two:
Collection |
Meaning |
Contents |
Contains the items that have been added to the session with a script command, Contents is the default collection for the Session object. |
StaticObjects |
Contains objects created by the object tag and given session scopes, which are created in the Global.asa file. |
Four, the Session object method, as table three:
Method |
Meaning |
Abandon |
Destroys the session object and releases its resources. |
Contents.Remove |
Deletes an item from the Contents collection. |
Contents.RemoveAll |
Deletes all items from the Contents collection. |
V. Session object events, such as table four:
Event |
Meaning |
Session_OnStart |
This event is generated when the session object is created. |
Session_OnEnd |
This event occurs when the session object is closed. |
See the full set of ASP Getting started tutorials