This is a very strange phenomenon which i have. My site works properly most of the time. But, from time to time (in the same session), some session info is not saved.
i've added at the end of my view:
request.session.modified = True
and in my settings, added:
SESSION_SAVE_EVERY_REQUEST = True
Also tried in the view:
request.session.save()
Still - nothing helps. From time to time, session information is not stored. i look at the Dbase and i see that it is indeed not saved.
im using django session with cached_db and PickleSerializer. Any idea?
To answer Iain - Below is the full session settings. but i also tried with file based session - same results.
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SESSION_SAVE_EVERY_REQUEST = True
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
}
}
also tried with other caches settings or no settings using the default:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}
The view has lost of logic in it. It ends with:
request.session.modified = True
my_logger.debug('question_list is %s' % request.session.get('question_list')) # the list exists
return HttpResponse(template_block)