![]() |
![]() |
|||||||||||||
|
Contents |
Contains the items you have added to the session with script commands. |
StaticObjects |
Contains items created in Global.asa using the <OBJECT> tag and given session scope. |
Properties
SessionID |
Returns the session identifier for this client. Each session has a unique identifier. |
Timeout |
The timeout period, in minutes, for session state for this application. |
Methods
Abandon |
Destroys a Session object and all object stored in it and releases their resources. |
Events
Session_OnStart |
Occurs when the server creates a new session. It runs before executing the requested page. |
Session_OnEnd |
Occurs when the session is abandoned or times out. |
Remarks
You can store values in the Session object. Information stored in the Session object is available for the entire session and has session scope. The following script demonstrates how two types of variables are stored:Session("username") = "Janine"
Session("age") = 42
If you are using VBScript as your scripting language, you must use the Set keyword to store an object in the Session object, as shown in the following example:<% Set Session("Obj1") = Server.CreateObject("MyComponent") %>
You can then call the methods and properties of Obj1 on subsequent Web pages by using the following syntax:<% Session("Obj1").MyObjMethod %>
As an alternative, you can extract a local copy of the object:Set MyLocalObj = Session("Obj1")
MyLocalObj.MyObjMethod
You cannot store a built-in object in a Session object. Each of the following lines will return an error:Set Session("var1") = Session
Set Session("var2") = Request
Set Session("var3") = Response
Set Session("var4") = Server
Set Session("var5") = Application
Before you store an object in the Session object, you must know what threading model it uses. Only objects marked as both free and apartment-threaded can be stored in the Session object.Session("StoredArray") (3) = "new value"
Instead of storing the value "new value" in StoredArray(3), the value is stored in the Session collection, overwriting any information stored at Session(3).Copyright © 2000 Chili!Soft