Simplified SessionMiddleware.process_response() a bit.

This commit is contained in:
Daniel Hahler 2019-05-29 14:04:42 +02:00 committed by Mariusz Felisiak
parent 480492fe70
commit 59f04d6b8f
1 changed files with 38 additions and 39 deletions

View File

@ -30,10 +30,9 @@ class SessionMiddleware(MiddlewareMixin):
modified = request.session.modified
empty = request.session.is_empty()
except AttributeError:
pass
else:
return response
# First check if we need to delete this cookie.
# The session should be deleted only if the session is entirely empty
# The session should be deleted only if the session is entirely empty.
if settings.SESSION_COOKIE_NAME in request.COOKIES and empty:
response.delete_cookie(
settings.SESSION_COOKIE_NAME,