CopyCode The Code is as follows: dim strname, iloop
For each strname in session. Contents
Response. Write strname & "-" & session. Contents (strname) & "[br]"
Next
generally, the above Code works well. However, when the session variable is an object or array, the printed result is incorrect. The code is modified as follows: copy Code the code is as follows: 'First, check how many session variables are used?
response. write "there are" & session. contents. count & _
"session variables
"
dim strname, iloop
'Use for each to view the session. contents
'If the session variable is an array?
If isarray (Session (strname) Then
'print every element of the array cyclically
for iloop = lbound (Session (strname )) to ubound (Session (strname)
response. write strname & "(" & iloop & ")-" & _
SESSION (strname) (iloop) & "
"
next
else
'in other cases, the variable value is simply printed.
response. write strname & "-" & session. CONTENTS (strname) & "
"
end if
next
the session variable sometimes cannot work. Why? There are many possibilities: First, if the client does not allow cookie operations, the session will become invalid. Because session is dependent on cookies. Second, the session has an expiration time. The default value is 20 minutes. You can modify it like this: web directory-> properties-> virtual directory-> application settings-> Configuration-> app options-> Session Timeout or write the following code in ASP: session. timeout = 60. Third, the session is related to the specific web application. If you browse/jobs/default. asp from/products/default. asp, the session may be created again. How to clear a session variable that is no longer needed but does not make the session invalid? In asp3.0: Session. Contents. Remove "variable name" can clear a variable. In asp2.0, set session ("variable name") = NULL can clear variables. In asp3.0, session. Contents. removeall can clear all session variables, which are different from session. Abandon. The above method will not make the current session expire or invalid. What does ASP mean at the top of a page? IIS uses a technology called session tracking to ensure that each session variable is available on each page. When you access an ASP page, IIS will first prepare various session variables for the page, which of course will affect the performance. (The cost of using session variables is always high !) If you have 100 pages and only five pages use the session, you only need to set the following settings on the five pages: copy Code the code is as follows: <% @ enablesessionstate = true %>
other page settings: copy Code the code is as follows: <% @ enablesessionstate = false %>