views:

87

answers:

2

In one view, I set:

request.session.set_expiry(999)
request.session['test'] = '123'

In another 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?

+1  A: 

Are you, by any chance, setting the session itself to an empty dictionary, somewhere?

Lakshman Prasad
A: 

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
Jesus Benito