From 9d9435588505a9e4c46af6a774ef5fb3dadf53db Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Thu, 25 Jan 2007 00:47:44 +0000 Subject: [PATCH] Fixed #2133 -- Invalid session cookie no longer causes fatal error. Thanks, greg-django@abbas.org git-svn-id: http://code.djangoproject.com/svn/django/trunk@4423 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/sessions/middleware.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/django/contrib/sessions/middleware.py b/django/contrib/sessions/middleware.py index 2337ad8a61..728caa7e19 100644 --- a/django/contrib/sessions/middleware.py +++ b/django/contrib/sessions/middleware.py @@ -1,5 +1,6 @@ from django.conf import settings from django.contrib.sessions.models import Session +from django.core.exceptions import SuspiciousOperation from django.utils.cache import patch_vary_headers import datetime @@ -55,7 +56,7 @@ class SessionWrapper(object): s = Session.objects.get(session_key=self.session_key, expire_date__gt=datetime.datetime.now()) self._session_cache = s.get_decoded() - except Session.DoesNotExist: + except (Session.DoesNotExist, SuspiciousOperation): self._session_cache = {} # Set the session_key to None to force creation of a new # key, for extra security.