_session_cache of SessionBase affected by database session engine save
|Reported by:||anonymous||Owned by:||nobody|
|Severity:||Normal||Keywords:||session dict disappear middleware save database|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I am running the exact same code on my local development machine and a production server.
Everything important I can think of is the same: both Ubuntu 13.10, both Python 2.7.5+, both Django 1.6.2, etc.
Yet the two machines are producing different behaviour!
I modified the file django/contrib/sessions/middleware.py, like so:
import sys sys.stderr.write('\nBefore!\n') for key, value in request.session.iteritems(): sys.stderr.write('%s=%s\n'%(key, value)) request.session.save() sys.stderr.write('\nAfter!\n') for key, value in request.session.iteritems(): sys.stderr.write('%s=%s\n'%(key, value))
So I am "printing" the session data before and after it is saved in the middleware.
On my machine, the data in question is present before and after (e.g. key = 'hello', value = '123'), but on the production server, the data in question is neither present before or after the save.
I have no idea how this is possible, but it's happening and driving me crazy.
Note: I am setting the session entry like so (in my view):
request.session['hello'] = '123'
So somewhere between that dict insertion and the middleware processing, the entry is completely disappearing, yet both machines are running identical code!
Change History (11)
comment:1 Changed 11 months ago by anonymous
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:8 Changed 11 months ago by Matt <carsrule@…>
- Summary changed from Session entry disappears before it can be saved to _session_cache of SessionBase affected by database session engine save