Web Hosting Offers
See the new scripts recently added to Dynamic Drive. Click here.
Original, practical CSS codes and examples such as CSS menus for your site.
    Search code samples  
 
  Keyword
 
 
 
   
 
 
  Code Samples
 
ASP
CSS
Dhtml
Html
Javascript
PHP
 
   
     LOGIN HERE  
 
Username
Password
Forgot Password
Verify Signup
 
 
 

ASP >> General

How can I list all of the existing Session variables for a particular user?

Visitor Ratings (0) :
Description

The Session object exposes the Contents collection as one of its properties. We can use a For Each ... Next loop to then step through each element of the Contents collection.

Dim strName, iLoop
'Use a For Each ... Next to loop through the entire collection
For Each strName in Session.Contents
Response.Write strName & " - " & Session.Contents(strName) & "<BR>"
Next

The above code will work flawlessly except when the user has assigned an array to a session variable. Therefore, we need to add an If statement in our For Each ... Next loop to determine whether or not the current session variable is an array. If it is, then we need to step through and display each element of the array.

Here is the revised code that will now gracefully handle/display session-level arrays:
Code
Select All
 Rate this Resource