|4GuysFromRolla.com : ASP FAQS : Session Object|
|Question:||For session variables to work, must the Web visitor have cookies enabled?|
|Answer:||Kind of. Session variables are bits of information that can be stored on a user-by-user basis. These bits of information are stored on the Web server. To tie these bits of memory with a particular user, for session variables to persist across Web pages, the user must have cookies enabled. When a user first visits a page on a site that uses Session variables, two things happen:|
-- A block of memory is allocated for that particular user's session variables on the Web server. This block of memory is identified by a unique SessionID
-- A cookie is written to the user's computer, storing the value of the SessionID
When the user visits another page on the site that uses session variables, the users SessionID cookie is referenced to determine if the user already has a session variable memory block setup. If he does, the values that are stored there are referenced. Through this mechanism, one can create seemingly "global" variables that persist from one page to another.
But what if the user doesn't have cookies enabled? Session variables can still be used, but there will be no way for the user to store the SessionID as he jumps from page to page. Hence, the session variables will not be saved for the user who has cookies disabled. However, session variables that are created and referenced on the same page will work fine. For example, the following script will output "Hello, World" regardless of whether or not the user has cookies enabled:
Of course, if, on another page, the value of
FAQ posted by Scott Mitchell at 9/26/2000 11:13:06 PM to the Session Object category. This FAQ has been viewed 133,635 times.
Copyright 2017 QuinStreet Inc. All Rights Reserved.
Advertise | Newsletters | E-mail Offers