From 13b37ed32a4a376d2d6e89f5fa9eb97da5146cb7 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Fri, 27 May 2011 02:18:23 +0200 Subject: [PATCH] Don't send session cookie unless session is dirty. --- wrw/session.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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 -- 2.11.0