ASP Tutorials - Herong's Tutorial Examples - v5.10, by Dr. Herong Yang
"session" Object - Sharing Data across ASP Pages
This section provides a tutorial example on how to use the 'session' object provided by the ASP programming interface to share data across ASP pages.
session: An object provided by the server to hold information and methods common to all ASP pages running under one session.
Here is a simple ASP page shows you the session object, session_test.asp:
<script language="vbscript" runat="server"> ' session_test.asp ' Copyright (c) 2002 by Dr. Herong Yang session("PATH_INFO") = request.ServerVariables("PATH_INFO") response.write("<html><body>") response.write("<b>Tests on the session object</b>:<br/>") response.write("session.SessionID = " & session.SessionID & "<br/>") set c = session.Contents response.write("session.Contents.Count = " & c.Count & "<br/>") for each v in c response.write( v & " = " & c.Item(v) & "<br/>") next response.write("</body></html>") </script>
Output:
Tests on the session object: session.SessionID = 1018427069 session.Contents.Count = 1 PATH_INFO = /session_test.asp
Note that session.Contents is empty initially. I added the "PATH_INFO" of the current request to it to show you how add and retrieve a parameter from session.Contents.
Table of Contents
ASP (Active Server Pages) Introduction
IIS (Internet Information Services) 5.0
►ASP Built-in Run-time Objects
"request" Object - Receiving Data from Client
"response" Object - Sending Data to Client
"server" Object - Sharing Data across Applications
"application" Object - Sharing Data within an Application
►"session" Object - Sharing Data across ASP Pages
Managing Sessions with and without Cookies
scrrun.dll - Scripting Runtime DLL
Managing Response Header Lines
Calculation Speed and Response Time
Working with MS Access Database