Some questions about session

xiaoxiao2021-03-06  48

How to get all the session variables? 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 reach your goals through the for ... EACH loop: DIM STRNAME, ILOOPFOR Each Strname In session.contentsResponse.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: '' Take a look at how many session variables are used? Response.write "There" & session.contents.count & _ "session variables

" DIM STRNAME, ILOOP '"use for Each loop View session.contents '' If the session variable is an array? If isarray (session (Strname) Then '' cycle printing array for each element for iLoop = lbound (session (Strname) RESPONSE .Write strname & "(" & iLoop & ") -" & _Session (ILOOP) & "
" NEXTELSE '", the value of simple print variables Response.write strname &" "& session .Contents (strname) & "
" End ifnextSession variables sometimes can't work, why? There are many possibilities: First, if the client does not allow cookie operations, the session will be invalid. Because session depends on cookie. Second, session has the setting of failure time. The default setting is 20 minutes. You can modify it this: Web Directory -> Properties -> Virtual Directory -> Application Settings -> Configuration -> App Options -> Session Timeout or in 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" can clear a variable. In ASP2.0: SET Session ("Variable Name) = NULL can clear the variable.

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

New Post(0)