2010-03-19 05:42:13 +00:00
|
|
|
from django.contrib.sessions.backends.base import SessionBase
|
|
|
|
|
2013-11-02 21:34:05 +00:00
|
|
|
|
2010-03-19 05:42:13 +00:00
|
|
|
class SessionStore(SessionBase):
|
|
|
|
"""
|
2011-06-12 16:33:40 +00:00
|
|
|
A simple cookie-based session storage implementation.
|
2010-03-19 05:42:13 +00:00
|
|
|
|
|
|
|
The session key is actually the session data, pickled and encoded.
|
|
|
|
This means that saving the session will change the session key.
|
|
|
|
"""
|
2022-02-03 19:24:19 +00:00
|
|
|
|
2010-03-19 05:42:13 +00:00
|
|
|
def __init__(self, session_key=None):
|
2017-01-21 13:13:44 +00:00
|
|
|
super().__init__(session_key)
|
2010-03-19 05:42:13 +00:00
|
|
|
|
|
|
|
def exists(self, session_key):
|
|
|
|
return False
|
|
|
|
|
|
|
|
def create(self):
|
2011-11-27 17:52:24 +00:00
|
|
|
self._session_key = self.encode({})
|
2010-03-19 05:42:13 +00:00
|
|
|
|
|
|
|
def save(self, must_create=False):
|
2011-11-27 17:52:24 +00:00
|
|
|
self._session_key = self.encode(self._session)
|
2010-03-19 05:42:13 +00:00
|
|
|
|
|
|
|
def delete(self, session_key=None):
|
2011-11-27 17:52:24 +00:00
|
|
|
self._session_key = self.encode({})
|
2010-03-19 05:42:13 +00:00
|
|
|
|
|
|
|
def load(self):
|
|
|
|
try:
|
|
|
|
return self.decode(self.session_key)
|
2015-11-15 18:52:47 +00:00
|
|
|
except Exception:
|
2010-03-19 05:42:13 +00:00
|
|
|
self.modified = True
|
2011-06-12 16:33:40 +00:00
|
|
|
return {}
|