2025-04-27 07:49:33 -04:00

108 lines
3.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
<TITLE>Session Contents Collection</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
TempString = navigator.appVersion
if (navigator.appName == "Microsoft Internet Explorer"){
// Check to see if browser is Microsoft
if (TempString.indexOf ("4.") >= 0){
// Check to see if it is IE 4
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
}
else {
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
}
}
else if (navigator.appName == "Netscape") {
// Check to see if browser is Netscape
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
}
else
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
//-->
</script>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub Window_OnLoad()
Dim frmContents
On Error Resume Next
If Not Parent Is Nothing Then
Set frmContents = Parent.Contents
If Not frmContents Is Nothing Then
frmContents.Window.TOCSynch_Click
End If
End If
End Sub
//--></SCRIPT><META NAME="DESCRIPTION" CONTENT="Internet Information Services reference information">
<META HTTP-EQUIV="PICS-Label" CONTENT='(PICS-1.1 "<http://www.rsac.org/ratingsv01.html>" l comment "RSACi North America Server" by "inet@microsoft.com <mailto:inet@microsoft.com>" r (n 0 s 0 v 0 l 0))'>
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META NAME="MS-IT-LOC" Content="Internet Information Services">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H4><A NAME="_session_contents_collection"></A><SUP></SUP>Session Contents Collection</H4>
<P>The <B>Session.Contents</B> collection contains all of the items that have been established for a session without using the &lt;OBJECT&gt; tag. The collection can be used to determine the value of a specific session item, or to iterate through the collection and retrieve a list of all items in the session.</P>
<H6>Syntax</H6>
<P><B>Session.Contents(</B> <I>Key</I> <B>)</B></P>
<P><B>&nbsp;</B></P>
<H6>Parameters</H6>
<DL>
<DT><I>Key</I></DT>
<DD>The name of the property to retrieve.</DD>
</DL>
<H6>Remarks</H6>
<P>You can use an iterating control structure to loop through the keys of the <B>Contents</B> collection. This is demonstrated in the following example.</P>
<PRE><CODE>&lt;%@ LANGUAGE="VBSCRIPT" %&gt;
&lt;%
Dim sessitem
Dim anArray(2)
response.write "SessionID: " &amp; Session.SessionID &amp; "&lt;P&gt;"
anArray(0)="one"
anArray(1)="second"
anArray(2)="third"
Session("anArray")=anArray
Session("scalar")="1234567890ABCDEFG"
set objConn=server.createobject("adodb.connection")
set Session("object")=objConn
response.write "List of " &amp; Session.Contents.Count &amp; " items in Session
contents collection:&lt;HR&gt;"
For Each sessitem in Session.Contents
If IsObject(Session.Contents(sessitem)) Then
Response.write(sessitem &amp; " : Session object cannot be displayed." &amp; "&lt;BR&gt;")
Else
If IsArray(Session.Contents(sessitem)) Then
Response.write "Array named " &amp; Session.Content(sessitem) &amp; "&lt;ol&gt;"
For each objArray in Session.Contents(sessitem)
Response.write "&lt;li&gt;" &amp; _
Session.Contents(sessitem)(objArray)&amp; "&lt;BR&gt;"
Next
Response.write "&lt;/ol&gt;"
Else
Response.write(sessitem &amp; " : " &amp; Session.Contents(sessitem) &amp; "&lt;BR&gt;")
End If
End If
Next
%&gt;
</CODE></PRE>
<hr class="iis" size="1">
<p align="center"><em><a href="../../../common/colegal.htm">&copy; 1997-2001 Microsoft Corporation. All rights reserved.</a></em></p>
</BODY>
</HTML>