||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:
Session("Message") = "Hello, World!"
Of course, if, on another page, the value of
Session("Message") is referenced, only those users who have cookies enabled will have a value of "Hello, World!" there.
For more information on Session variables (and info on maintaining state, in general, on the Web), be sure to read the sample chapter from my book,
Sams Teach Yourself Active Server Pages 3.0 in 21 Days!