|
Session Object
The Session Object is used to store information about or change
settings for the user's current Web-server session.
Syntax
Session.collection
Session.property
Session.method
Collections
Collection Description
Contents Holds the items added to the session with script
commands
StaticObjects Holds the objects added to the session with the
<object> tag, and a
given session
Properties
Property Description
CodePage Sets the code page that will be used to display dynamic
content
LCID Sets the locale identifier that will be used to display
dynamic content
SessionID Returns the session id
Timeout Sets the timeout for the session
Method
Method Description
Abandon Kills all objects in a session object
Contents.Remove(Item or Index) Deletes an item from the
Contents collection
Contents.RemoveAll() Deletes all items from the Contents
collection
Events
Event Description
OnEnd What to do when a session is over. This event will execute
a script in the
Global.asa file, if the script exist
OnStart What to do before the start of any new session. This
event will execute a script
in the Global.asa file, if the script exist
Examples
1. Session Id
This example demonstrates the "SessionID" property. This
property returns the session id number for each user (it is a
read-only property). The session id number is generated by the
server.
Coding
<html>
<body>
<%
Response.Write(Session.SessionID)
%>
</body>
</html>
Output
332916080
2. Get a Session's Timed Out
This example demonstrates the "Timeout" property. This example
retrieves the timeout (in minutes) for the session. The default
value for the "Timeout" property is 20 minutes.
Coding
<html>
<body>
<p>
The timeout for this session is
<%
Response.Write(Session.Timeout)
%>
minutes.
</p>
</body>
</html>
Output
The timeout for this session is 20 minutes.
|