News:

GinGly.com - Used by 85,000 Members - SMS Backed up 7,35,000 - Contacts Stored  28,850 !!

Main Menu

ASP - Loop Through the Contents Collection

Started by sukishan, Jul 13, 2009, 12:48 PM

Previous topic - Next topic

sukishan

The Contents collection contains all session variables. You can loop through the Contents collection, to see what's stored in it:
<%
Session("username")="Donald Duck"
Session("age")=50

dim i
For Each i in Session.Contents
  Response.Write(i & "
")
Next
%>

Result:

username
age

If you do not know the number of items in the Contents collection, you can use the Count property:

<%
dim i
dim j
j=Session.Contents.Count
Response.Write("Session variables: " & j)
For i=1 to j
  Response.Write(Session.Contents(i) & "
")
Next
%>

Result:

Session variables: 2
Donald Duck
50
A good beginning makes a good ending