equal
deleted
inserted
replaced
|
1 from django.contrib.sessions.backends.base import SessionBase |
|
2 |
|
3 class SessionStore(SessionBase): |
|
4 """ |
|
5 A simple cookie-based session storage implemenation. |
|
6 |
|
7 The session key is actually the session data, pickled and encoded. |
|
8 This means that saving the session will change the session key. |
|
9 """ |
|
10 def __init__(self, session_key=None): |
|
11 super(SessionStore, self).__init__(session_key) |
|
12 |
|
13 def exists(self, session_key): |
|
14 return False |
|
15 |
|
16 def create(self): |
|
17 self.session_key = self.encode({}) |
|
18 |
|
19 def save(self, must_create=False): |
|
20 self.session_key = self.encode(self._session) |
|
21 |
|
22 def delete(self, session_key=None): |
|
23 self.session_key = self.encode({}) |
|
24 |
|
25 def load(self): |
|
26 try: |
|
27 return self.decode(self.session_key) |
|
28 except: |
|
29 self.modified = True |
|
30 return {} |