Opened 11 years ago

Closed 11 years ago

#5593 closed (fixed)

Missing DB sessions create a new session for every request

Reported by: nezroy <nezroy@…> Owned by: nobody
Component: contrib.sessions Version: master
Severity: Keywords: session invalid stale duplicate clutter
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When using the DB SessionStore, it's possible to start getting a bunch of invalid sessions in the session table. This happens when an original session has been purged from the table, but a client still has the old, stale cookie with the original session ID. The load method will create a new session with a new id for security purposes when it tries to load this old session, but it does *not* update the actual cookie stored on the client. So the client continues to try and use the old session id, which keeps causing the load method to create new sessions with new IDs.

Attached is a simple patch that is the simplest solution I could think of, though I'm not familiar enough with session to understand potential ramifications. The load function is simply updated to set the "modified" property to True so that further processing in the response handler will send an updated version of the cookie to the client.

Attachments (1)

stale_sessionid.patch (437 bytes) - added by nezroy <nezroy@…> 11 years ago.
Patch to force client update of sessionid cookie.

Download all attachments as: .zip

Change History (4)

Changed 11 years ago by nezroy <nezroy@…>

Attachment: stale_sessionid.patch added

Patch to force client update of sessionid cookie.

comment:1 Changed 11 years ago by Simon G <dev@…>

Triage Stage: UnreviewedReady for checkin

Hmm.. I'll push this to RFC as it's kind of important, and a one-liner. If core thinks there's a better way to do this, can they revert it?

comment:2 Changed 11 years ago by Jacob

Triage Stage: Ready for checkinAccepted

We need to look at this closer to know if this is the right approach.

comment:3 Changed 11 years ago by Ramiro Morales

Resolution: fixed
Status: newclosed

This has been fixed on [7001] with a similar but more comprehensive patch (it laso fixes the problemn on the file-based session backend engine). See discussion at

Note: See TracTickets for help on using tickets.
Back to Top