Index: pokernetwork/pokersite.py
===================================================================
--- pokernetwork/pokersite.py	(revision 6386)
+++ pokernetwork/pokersite.py	(working copy)
@@ -154,8 +154,6 @@
         self.expired = True
     
     def checkExpired(self):
-        if self.expired:
-            return False
         try:
             #
             # The session may expire as a side effect of the
@@ -165,8 +163,17 @@
             # session already expired.
             #
             self.site.getSession(self.uid, self.auth, self.explain_default)
-            server.Session.checkExpired(self)
-            return True
+            #
+            # The session may be replaced by a new session as a side
+            # effect of the verifications made by getSession against
+            # memcache. When this happens no exception is thrown and
+            # checkExpired should not be called because the session
+            # has already expired.
+            #
+            if not self.expired:
+                server.Session.checkExpired(self)
+                return True
+            return False
         except KeyError:
             return False
         
Index: tests/test-pokersite.py.in
===================================================================
--- tests/test-pokersite.py.in	(revision 6386)
+++ tests/test-pokersite.py.in	(working copy)
@@ -738,6 +738,16 @@
             session.expire()
             session.checkExpired()
 
+      def test03_replaceFromGetSession(self):
+            uid = 'uid'
+            auth = 'auth'
+            session = self.site.makeSessionFromUidAuth(uid, auth, 'yes')
+            session.avatar.user.serial = 5
+            session.lastModified = 0
+            self.site.memcache.set(uid, '0')
+            self.site.memcache.set(auth, '0')
+            self.assertEqual(False, session.checkExpired())
+
 class RequestTestCase(PokerSiteBase):
 
       def test01_name(self):
