In Django, my request.session is not carrying over...does anyone know why?
In one view, I set:
request.session.set_expiry(999)
request.session['test'] = '123'
In an开发者_高级运维other view, I do:
print request.session['test']
and it cannot be found. (error) It's very simple, I just have 2 views.
It seems that once I leave a view and come back to it...it's gone! Why?
Could it be related to this?, just found it at http://code.djangoproject.com/wiki/NewbieMistakes
Appending to a list in session doesn't work Problem
If you have a list in your session, append operations don't get saved to the object. Solution
Copy the list out of the session object, append to it, then copy it back in:
sessionlist = request.session['my_list']
sessionlist.append(new_object)
request.session['my_list'] = sessionlist
Are you, by any chance, setting the session itself to an empty dictionary, somewhere?
精彩评论