Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

1 total

asp :: Displaying Session and Application variables

Often when using ASP or Active Server Pages you will find it necessary to do some troubleshooting. Below is some neat code you can run that will show you all the current Session and Application variables and really give you a good idea of what sort of information is being saved in them. At the bottom of this page we also show you a way to erase/clear all this information all at once.

<font face=arial size=1>
Session Variables - <% =Session.Contents.Count %> Found<br><br>
<%
Dim item, itemloop
For Each item in Session.Contents
  If IsArray(Session(item)) then
    For itemloop = LBound(Session(item)) to UBound(Session(item))
%>
<% =item %>  <% =itemloop %> <font color=blue><% =Session(item)(itemloop) %></font><BR>
<%
    Next
  Else
%>
<% =item %> <font color=blue><% =Session.Contents(item) %></font><BR>
<%
  End If
Next
%>

<hr>

Application Variables - <% =Application.Contents.Count %> Found<br><br>
<%
For Each item in Application.Contents
  If IsArray(Application(item)) then
    For itemloop = LBound(Application(item)) to UBound(Application(item))
%>
<% =item %>   <% =itemloop %> <font color=blue><% =Application(item)(itemloop) %></font><BR>
<%
    Next
  Else
%>
<% =item %> <font color=blue><% =Application.Contents(item) %></font><BR>
<%
  End If
Next
%>
</font>

Additionally, here is some handy code you can run that will wipe that information clean.

<%
Session.Abandon
Application.Contents.RemoveAll()
%>

1 total