From d77236960a5d3792bf9514fb7834d2813f531054 Mon Sep 17 00:00:00 2001
From: Malcolm Tredinnick <malcolm.tredinnick@gmail.com>
Date: Sun, 1 Mar 2009 07:32:41 +0000
Subject: [PATCH] Fixed #9548 -- Correctly detect existence of empty sessions
 with cache backend.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9934 bcc190cf-cafb-0310-a4f2-bffc1f526a37
---
 django/contrib/sessions/backends/cache.py | 2 +-
 django/contrib/sessions/tests.py          | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/django/contrib/sessions/backends/cache.py b/django/contrib/sessions/backends/cache.py
index 5fdf133b05..ab0716dcb4 100644
--- a/django/contrib/sessions/backends/cache.py
+++ b/django/contrib/sessions/backends/cache.py
@@ -43,7 +43,7 @@ class SessionStore(SessionBase):
             raise CreateError
 
     def exists(self, session_key):
-        if self._cache.get(session_key):
+        if self._cache.has_key(session_key):
             return True
         return False
 
diff --git a/django/contrib/sessions/tests.py b/django/contrib/sessions/tests.py
index d0fed280b5..f0a3c4ec8c 100644
--- a/django/contrib/sessions/tests.py
+++ b/django/contrib/sessions/tests.py
@@ -182,6 +182,11 @@ False
 False
 >>> cache_session.items() == prev_data
 True
+>>> cache_session = CacheSession()
+>>> cache_session.save()
+>>> key = cache_session.session_key
+>>> cache_session.exists(key)
+True
 
 >>> Session.objects.filter(pk=cache_session.session_key).delete()
 >>> cache_session = CacheSession(cache_session.session_key)