File tree Expand file tree Collapse file tree 3 files changed +19
–2
lines changed
django/contrib/sessions/backends Expand file tree Collapse file tree 3 files changed +19
–2
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ def flush(self):
7979 """
8080 self .clear ()
8181 self .delete (self .session_key )
82- self ._session_key = ''
82+ self ._session_key = None
8383
8484# At bottom to avoid circular import
8585from django .contrib .sessions .models import Session # isort:skip
Original file line number Diff line number Diff line change @@ -4,7 +4,23 @@ Django 1.8.2 release notes
44
55*Under development*
66
7- Django 1.8.2 fixes several bugs in 1.8.1.
7+ Django 1.8.2 fixes a security issue and several bugs in 1.8.1.
8+
9+ Fixed session flushing in the ``cached_db`` backend
10+ ===================================================
11+
12+ A change to ``session.flush()`` in the ``cached_db`` session backend in Django
13+ 1.8 mistakenly sets the session key to an empty string rather than ``None``. An
14+ empty string is treated as a valid session key and the session cookie is set
15+ accordingly. Any users with an empty string in their session cookie will use
16+ the same session store. ``session.flush()`` is called by
17+ ``django.contrib.auth.logout()`` and, more seriously, by
18+ ``django.contrib.auth.login()`` when a user switches accounts. If a user is
19+ logged in and logs in again to a different account (without logging out) the
20+ session is flushed to avoid reuse. After the session is flushed (and its
21+ session key becomes ``''``) the account details are set on the session and the
22+ session is saved. Any users with an empty string in their session cookie will
23+ now be logged into that account.
824
925Bugfixes
1026========
Original file line number Diff line number Diff line change @@ -162,6 +162,7 @@ def test_flush(self):
162162 self .session .flush ()
163163 self .assertFalse (self .session .exists (prev_key ))
164164 self .assertNotEqual (self .session .session_key , prev_key )
165+ self .assertIsNone (self .session .session_key )
165166 self .assertTrue (self .session .modified )
166167 self .assertTrue (self .session .accessed )
167168
You can’t perform that action at this time.
0 commit comments