Display and disappearance of mouse moving time on text

xiaoxiao2021-03-05  20

In program debugging, sometimes you need to know how many session variables are used, what is their value? Since the session object provides a collection called Contents, we can get the goal through the for ... EACH loop:

DIM STRNAME, ILOOP

For Each Strname in Session.Contents

Response.Write Strname & "-" & session.contents (strname) & "
"

NEXT

Under normal circumstances, the above code can work very well. But when the session variable is an object or array, the result of printing is not correct.

This way we modify the code as follows:

'First see how many session variables are used?

Response.write "There Are" & session.contents.count & _

"Session Variables

"

DIM STRNAME, ILOOP

'Use for Each Cycling to see session.contents

'If the session variable is an array?

IF isarray (session (strname) then

'Cyclic print array of each element

For iLoop = lbound (session (Strname) to Ubound (session (Strname)

Response.Write Strname & "(" & iLoop & ") -" & _

Session (Strname) & "
"

NEXT

Else

'Other situations, simply print variables

Response.Write Strname & "-" & session.contents (strname) & "
"

END IF

NEXT

The session variable is sometimes can't work, why?

There are many possibilities:

First, if the client does not allow cookie operations, the session will fail. Because session depends on cookie.

Second, session has the setting of failure time. The default setting is 20 minutes. You can modify it like this: Web Directory -> Properties -> Virtual Directory -> Application Settings -> Configuration -> App Options -> Session Timeout

Or in the ASP, write this code: session.timeout = 60.

Third, Session is related to the specific web application. If the user browses to /jobs/default.asp from /products/default.asp, it may also cause recreate of session.

How to clear a session variable that is no longer need but does not make session?

In ASP3.0:

Session.contents.remove "variable name"

A variable can be cleared.

In ASP2.0:

SET session ("Variable Name) = NULL

Variables can be removed.

In ASP3.0,

Session.contents.removeall

You can clear all session variables and session.abandon, and the above methods will not expire or invalidate the current session. <% @ EnableSessionState = true%> What is the top of the ASP page?

IIS uses a technology called session tracking to ensure that each session variable is available in each page. When the user accesses an ASP page, IIS will first prepare each session variable for this page, which of course will bring performance. (The cost of using the session variable is always very high!)

If you have 100 pages, only 5 pages have been used in Session, then, for the overall performance, you only need to set it in that 5 page:

<% @ EnablesessionState = true%>

And other pages are set to:

<% @ EnablesessionState = false%>

转载请注明原文地址:https://www.9cbs.com/read-38677.html

New Post(0)