diff --git a/django/contrib/auth/__init__.py b/django/contrib/auth/__init__.py
index f11f830..21470cd 100644
a
|
b
|
def login(request, user):
|
61 | 61 | if user is None: |
62 | 62 | user = request.user |
63 | 63 | # TODO: It would be nice to support different login methods, like signed cookies. |
64 | | if SESSION_KEY in request.session: |
65 | | if request.session[SESSION_KEY] != user.id: |
66 | | # To avoid reusing another user's session, create a new, empty |
67 | | # session if the existing session corresponds to a different |
68 | | # authenticated user. |
69 | | request.session.flush() |
70 | | else: |
| 64 | if request.session.get(SESSION_KEY) != user.id: |
71 | 65 | request.session.cycle_key() |
72 | 66 | request.session[SESSION_KEY] = user.id |
73 | 67 | request.session[BACKEND_SESSION_KEY] = user.backend |
… |
… |
def logout(request):
|
87 | 81 | user = None |
88 | 82 | user_logged_out.send(sender=user.__class__, request=request, user=user) |
89 | 83 | |
90 | | request.session.flush() |
| 84 | request.session.pop(SESSION_KEY, None) |
| 85 | request.session.pop(BACKEND_SESSION_KEY, None) |
91 | 86 | if hasattr(request, 'user'): |
92 | 87 | from django.contrib.auth.models import AnonymousUser |
93 | 88 | request.user = AnonymousUser() |