0

I'm currently running a Django application with SESSION_ENGINE configured as django.contrib.sessions.backends.cache. I'd like to change this to django.contrib.sessions.backends.cached_db to gain persistence.

Can I make this change without destroying the existing sessions?

Chris Martin
  • 30,334
  • 10
  • 78
  • 137

1 Answers1

1

The cache and cached_db session backends use a different key prefix to store the sessions in cache. If you just change the session engine, you will not be able to access the old sessions.

You could write a simple SessionStore that subclasses the cached_db session store and overrides load() and exists() to check the old key first.

knbk
  • 52,111
  • 9
  • 124
  • 122