Posted: July 3rd, 2010 | Author: Arif Harbott | Filed under: Django | Tags: session, sessionkey | No Comments »
If you use the request.session.session_key for an anonymous user e.g. to store shopping cart information, and then use django.contrib.auth login be aware that the session key will change. This tends to catch out new Django developers.
Posted: February 1st, 2010 | Author: Davo | Filed under: Django | Tags: append, array, Django, session | 1 Comment »
I was trying to save and update some arrays inside the Django session object but it was not working at all…
The following snippet DOES NOT WORK
request.session['array'] = [] # let's create an empty array
# try to append some integers...
request.session['array'].append(1)
request.session['array'].append(2)
request.session['array'].append(3)
...
In order to solve this we need to store the array in a temporary object first.
Quick fix:
request.session['array'] = []
tmp = request.session['array']
tmp.append(1)
tmp.append(2)
tmp.append(3)
request.session['array'] = tmp # this works now.
...