While the approach suggested by nnmware may work for this particular case, there is a better one.
Instead of doing anything inside cycle_key , we should call the super method and then save the session.
Because if you look inside the original cycle_key function, you will see that the data from the old session is copied to the new, but not really saved.
In settings.py
SESSION_ENGINE = 'yourapp.session_backend'
Make sure that SESSION_ENGINE points to the module (.py file), but not to the base class!
Now, in your 'yourapp / session_backend.py', do the following:
from django.contrib.sessions.backends.db import SessionStore as DbSessionStore class SessionStore(DbSessionStore): def cycle_key(self): super(SessionStore, self).cycle_key() self.save()
mennanov
source share