You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-dev@quetz.apache.org by Barry Pederson <bp...@barryp.org> on 2003/08/18 00:57:28 UTC
Session timeout problem
This is an easy one...
In the snapshot http://www.modpython.org/tmp/httpd-python-20030814.tgz
the BaseSession.__init__() method checks for a session timing out, and
if it's expired, it makes a new session. However, the old session's
data is still hanging around and is carried over into the new session.
There probably should be a call to self.clear() somewhere in there,
perhaps at the end of Session.delete()?
Here's a bit of demo code. Every time you reload the page, the count
stored in the session increases by one, even if you wait longer than 30
seconds and have a new session created.
----------------
import time
from mod_python.Session import Session
def index(req):
sess = Session(req)
count = sess.get('count', 0) + 1
sess['count'] = count
sess.set_timeout(30)
sess.save()
return 'is_new(): %d count: %d, time: %s' % (sess.is_new(), count,
time.strftime('%Y-%m-%d %H:%M:%S'))
-----------------
Barry
Re: Session timeout problem
Posted by "Gregory (Grisha) Trubetskoy" <gr...@apache.org>.
Yes, I think adding a self.clear() after self.do_delete() (line 240) would
do it.
P.S. I'm still trying to figure out the graceful restart problem.
Grisha
On Sun, 17 Aug 2003, Barry Pederson wrote:
> This is an easy one...
>
> In the snapshot http://www.modpython.org/tmp/httpd-python-20030814.tgz
> the BaseSession.__init__() method checks for a session timing out, and
> if it's expired, it makes a new session. However, the old session's
> data is still hanging around and is carried over into the new session.
>
> There probably should be a call to self.clear() somewhere in there,
> perhaps at the end of Session.delete()?
>
> Here's a bit of demo code. Every time you reload the page, the count
> stored in the session increases by one, even if you wait longer than 30
> seconds and have a new session created.
>
> ----------------
> import time
> from mod_python.Session import Session
>
> def index(req):
> sess = Session(req)
> count = sess.get('count', 0) + 1
> sess['count'] = count
> sess.set_timeout(30)
> sess.save()
> return 'is_new(): %d count: %d, time: %s' % (sess.is_new(), count,
> time.strftime('%Y-%m-%d %H:%M:%S'))
> -----------------
>
> Barry
>