Implementing Session Support

For the remainder of this chapter, we’ll discuss how to provide session support that uses active client identification and server-side storage of session records in a database. We’ll also write a few applications that demonstrate how to implement sessions, using the following general procedure:

1.
When a user connects initially, generate a random session ID, send it to the client, and initialize a session record in the database.
2.
As each subsequent request arrives from the user, extract the session ID and use it to retrieve the session record. Update the record as necessary using any new information in the request.
3.
At the end of each request, take one of two actions: Close the session if you still need it ...

Get MySQL and Perl for the Web now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.