
400
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Chapter 19SessionState Class
19
The HttpSessionState Class
A significant challenge for any Web-based application is managing user state.
Unlike rich client applications, in which user state can be stored in persistent vari-
ables local to the client application, web browsers do not have a comparable built-
in facility for persistently storing user state locally. This is because HTTP, the
basic communication protocol used in web applications, is essentially a connec-
tionless protocol (the HTTP specification allows persistent connections, but
problems with persistent HTTP connections prevent this specification from being
widely used). Each HTTP request/response is treated as completely separate from
every other request/response. As such, any local variable storage cannot be reli-
ably mapped from the request/response in which they were created to any
subsequent request/response.
An early solution to this challenge was the creation of cookies, which are bits of
text that are stored either in memory (per-session cookies) or on disk (persistent
cookies) and are associated with the domain name from which they originated.
This solves the problem of being able to associate a bit of data with more than one
request/response, but it has limitations that made it a less than ideal solution:
•