|   
							 
								Getting the Values of all the Session and Application Variables   | 
							    |      |      |                      |           Submitted on: 9/20/2002 2:29:57 PM 
						By: John Tolar 
						 
						Level: Beginner User Rating: Unrated   Compatibility:ASP (Active Server Pages)
  Users have accessed this article 2259 times.   |     (About the author) |  
  |          |   |                 This is a quick way to get a listing of all of your Session variables and\or Application Variables. It even Accounts for arrays stored in Session\Application Variables.         |    | 
|   | 
            Terms of Agreement:    
	 By using this article, you agree to the following terms...    
	 1) You may use 
	 this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.    
	 2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.    
	 3) You may link to this article from another website, but ONLY if it is not wrapped in a frame.  
	 4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.   |      'Set some test data here.
    dim arSessionVar(2)
    arSessionVar(0) = "Array Value 0"
    arSessionVar(1) = "Array Value 1"
    arSessionVar(2) = "Array Value 2"
    Session("arSessionVar") = arSessionVar
    Session("Var1") = "TEST"
    Session("AnotherVar") = "Another Var"
    Application("TestAppVar") = 1
    Application("AnotherAppVar") = "two"
    Application("Test Var") = "Another Test for Application Vars"
    Application("arAppVar") = arSessionVar
    'Loop through the Session Collection and
    '     display the variables.
    Response.Write " SESSION VARIABLES "
    For each SessionVar in Session.Contents 
    	If IsArray(Session(SessionVar)) then
    		arNewArray = Session(SessionVar)
    		For i = 0 to ubound(arNewArray)
    			Response.Write SessionVar & "(" & i & ") = " & arNewArray(i) & " "
    		Next
    	Else
    		Response.Write SessionVar & " = " & Session(SessionVar) & " "
    	End If 
    Next
    'Loop through the Application Collection
    '     and display the variables.
    Response.Write " APPLICATION VARIABLES "
    For each AppVar in Application.Contents 
    	If IsArray(Application(AppVar)) then
    		arNewArray = Application(AppVar)
    		For i = 0 to ubound(arNewArray)
    			Response.Write AppVar & "(" & i & ") = " & arNewArray(i) & " "
    		Next
    	Else
    		Response.Write AppVar & " = " & Application(AppVar) & " "
    	End If 
    Next
 |    | 
   Other 3 submission(s) by this author
  | 
   |   
|   | 
| Report Bad Submission | 
   | 
 |   | 
| Your Vote! | 
| 
See Voting Log  | 
|   | 
| Other User Comments | 
9/22/2002 2:41:42 AM:Sam Moses interesting.
Seems a bit complex for 
the task though.
Using a couple of 
stratigically placed for statements, I 
would imagine you could cut your line 
count down. Just a thought.  
  | 
9/22/2002 9:54:43 AM: Can't get the code to work, can you 
repost it cleaned up.  Thanks  
  | 
 | 
    |   Add Your Feedback! |   
    Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.
  NOTICE: The author of this article has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.
  For feedback not related to this particular article, please click here.     |   
   |