diff MoinMoin/web/session.py @ 5580:af56baebf4d1

sessions: fix expiry check
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 23 Feb 2010 23:45:09 +0100
parents e535351eab08
children dba48cb280f9
line wrap: on
line diff
--- a/MoinMoin/web/session.py	Tue Feb 23 23:17:50 2010 +0100
+++ b/MoinMoin/web/session.py	Tue Feb 23 23:45:09 2010 +0100
@@ -306,13 +306,15 @@
             session = store.new()
         else:
             session = store.get(sid)
-            now = time.time()
-            expiry = session.get('expires', 0)
-            if expiry < now:
-                # the browser should've killed that cookie already.
-                # clock not in sync? trying to cheat?
-                self.destroy_session(request, session)
-                session = store.new()
+            expiry = session.get('expires')
+            if expiry is not None:
+                now = time.time()
+                if expiry < now:
+                    # the browser should've killed that cookie already.
+                    # clock not in sync? trying to cheat?
+                    logging.debug("session has expired (expiry: %r now: %r)" % (expiry, now))
+                    self.destroy_session(request, session)
+                    session = store.new()
         logging.debug("get_session returns session %r" % session)
         return session