09-23-04 02:20 PM
"Yan Zhou" <yzhou@medplus.com_REMOVE> writes:
> I have no problem with performance or synchronization, but I would like to
> know what are some strategys to keep session states since different
> processes/threads can serve requests within the same user session.
This is a basic problem with trying to use a stateless protocol for a
stateful application. Fortunately, since it's so basic, everybody has
solved it already. Whatever language you are using will have at least
several mechanisms for keeping session state. In the case of Perl,
several hundred, most likely.
I strongly recommend you look into the tools provided by whatever
language you're writing your code in, and use those, instead of trying
to reinvent them.
To specifically answer your question, the basic idea is that you
associate some unique ID with a session, and then store the
information associated with that session on the server somewhere, and
store the ID with the user somehow (either via a cookie, or via
rewriting URLs to include the session ID somehow).
Then, each time the user requests a resource, you are also handed the
session ID, which you then use to fetch the session information back
from wherever you stored it. Again, there exist modules right now for
nearly every language that will store session information in shared
memory, in files, in databases, and who knows where else. Use them.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
[ Post a follow-up to this message ]
|