Simplified SessionMiddleware.process_response() a bit.
@@ -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,
