Forum Moderators: open

Message Too Old, No Replies

Session Variables and ASP

         

tesla

3:45 pm on Aug 31, 2002 (gmt 0)

10+ Year Member




Is there any general restrictions on Session Variable names, number of variables, or data size of session variables?

Where are the variables stored? Are they stored along with the cookie on the users machine or are they kept on the server.

If the variables are stored on the server, there use should be as fast as any variable passed between pages using Request("data") statements.... Right?

Is there anything to watch out for when using Session Variables?
Any special clean up necessary?

Thanks,

v_1_c

3:56 pm on Aug 31, 2002 (gmt 0)

10+ Year Member



All session info is stored on the server hosting the ASP page and all that is on the cookie is the SID (session id) to link the session info with the specific visitor .

As for clean up , either set the expiry time lower or have a log out section that links to a page with

<%
Session.Abandon
%>

to destroy the users session and free up system resources

v1c

Xoc

4:08 pm on Aug 31, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The session info is stored in the memory of the web server. As v_1_c said, it is referenced by a session id number placed into a cookie on the end user's machine. There is a timeout, by default 20 minutes, by which the cookie and the session info on the server will be deleted if that session id isn't referenced.

The implications are huge.

  1. Don't store anything large in a session variable. Objects are a definite no-no to store in a variable.
  2. Using any session variables at all will kill the web server if there is a massive run on the server.
  3. Max out the memory on the web server. The more memory, the more sessions you can handle.
  4. If you aren't using session variables, turn off sessions on the server.
  5. When you are done, abandon the session as shown above.

tesla

4:18 pm on Aug 31, 2002 (gmt 0)

10+ Year Member




I plan to store about 8 simple, short text and number variables.

Is there a way to limit the amount of memory allocated to each variable so as to minimize the amount of memory consumed overall?

Is this type of storage more consuming than a common local ASP variable? I suppose because of the timeout it will persist longer and as a result, is more consuming.

Thanks,

Xoc

4:22 pm on Aug 31, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's exactly the sort of thing you want stored in session variables. Text and numbers. Not something huge such as a recordset. To limit the memory, just make sure you don't store the text for Hamlet in the text variables.

A simple ASP variable is discarded from memory as soon as the page is delivered. A session variable waits, by default, 20 minutes from the last hit by that session on the web server before it is discard, unless the session is abandoned.

v_1_c

4:46 pm on Aug 31, 2002 (gmt 0)

10+ Year Member



Dont use session unless needed , also make sure that your visitors have cookies enabled . If you use something like PHP you have a lot more flexability and control of you sessions than ASP provides , just a thought . Apply everything said in this post to application variables as well .

v1c