|
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:
|