To read the article online, visit http://www.4GuysFromRolla.com/webtech/tips/t030100-1.shtml

User Tips: Listing the Contents of the Session and Application Objects


By Stephen V.

Here's a page I wrote to show the contents of the session and application collections. It has proved pretty useful for me, and I figure if I can save someone else time writing it, then more power to me. :)

This code will show the contents of arrays in a collection, but it will not show the contents of arrays within arrays within a collection (how's that for confusing?). A more ambitious coder could easily modify it to recurse more deeply, but I hope few people are actually putting array arrays into the session/application.

<%
dim item 'will be used to iterate through the contents %>
<html>
<head>
  <title>Collection Information</title>
</head>
<body>
<table>
<tr>
	<th colspan=2>Session</th>
</tr>
<%
  'In case a particular item gives us trouble
  on error resume next

  for each item in Session.Contents  %>
   <tr>
	<td><%=item%></td>  <%'Show the item's name %>
	<TD><%=dumpitem(Session(item))%> <%'Show the Item's contents%>
	</td>
   </tr>
<%
   next 'For each%>
</table>

<table>
<Tr>
	<th colspan=2>Application</th>
</tr>
<% for each item in Application.Contents  %>
   <tr>
	<td><%=item%></td>
	<TD><%=dumpItem(application(item))%></td>
   </tr>
<% next %>
	
<%
   function dumpItem(item)
        'If it's an array we use this to iterate through it
        dim subItem
        dim result  'Will store the result

        'If it's an array we have to
        'grab its contents.  
        if TypeName(item) = "Variant()" then 
          for each subItem in item
             'Separate each with a space
             result = result & " " & subItem
          next
        else
          result = item
        end if

        dumpItem = result
    end function
%>

Happy Programming!

Return to user tips...


Article Information
Article Title: User Tips: Listing the Contents of the Session and Application Objects
Article Author: Stephen V.
Article URL: http://www.4GuysFromRolla.com/webtech/tips/t030100-1.shtml


Copyright 2017 QuinStreet Inc. All Rights Reserved.
Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers