From: Fredrik Tolf Date: Fri, 27 May 2011 00:18:23 +0000 (+0200) Subject: Don't send session cookie unless session is dirty. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=13b37ed32a4a376d2d6e89f5fa9eb97da5146cb7;p=wrw.git Don't send session cookie unless session is dirty. --- diff --git a/wrw/session.py b/wrw/session.py index 1fded4a..9e91ad9 100644 --- a/wrw/session.py +++ b/wrw/session.py @@ -129,18 +129,17 @@ class db(object): except KeyError: sess = session() self.live[sess.id] = sess - req.oncommit(self.addcookie) + sess.new = True req.oncommit(self.ckfreeze) return sess - def addcookie(self, req): - sess = req.item(self.fetch) - cookie.add(req, self.cookiename, sess.id, self.path) - def ckfreeze(self, req): sess = req.item(self.fetch) if sess.dirty(): try: + if getattr(sess, "new", False): + cookie.add(req, self.cookiename, sess.id, self.path) + del sess.new self.freeze(sess) except: pass