|
John Mudd
mudd at vex.net
Mon Apr 5 15:30:49 EST 2004
Oh, I just found some code from an old version that looks like it should
work. But I deleted it. I can't remember now why I dropped it.
Does this (if cookies.has_key('pysid')) look like a reasonable way to
tell if a new session is for a truly first time (virgin) user?
# Get any ccookies.
cookies = Cookie.get_cookies(req, Cookie.MarshalCookie,
secret=secretKey)
# Either read the existing session (if any) or create a new one.
session = Session.Session(req, None, secretKey, timeout)
# Was it necessary to create a new session object?
if session.is_new():
# Was there an old session but it expired?
if cookies.has_key('pysid'):
sessionStatus = 'expired'
else:
sessionStatus = 'new'
On Wed, 2004-03-31 at 15:02, John Mudd wrote:
> Thanks.
>
> I started to add my own time stamp and then realized that even that
> won't solve my original problem.
>
> What I really want to know if whether a new session object was created
> because (1) there was never a session for this client before or (2) the
> previous session has since expired. I can tell if a session object is
> new thanks to the is_new() method but not whether an old session
> expired. If I know then I can tell the client user why they have to
> login again (e.g. the session expired).
>
> John
>
>
> On Wed, 2004-03-31 at 14:52, Gregory (Grisha) Trubetskoy wrote:
> > This is a bug clearly... I suppose a workaround would be to store your own
> > date until we have this fixed.
> >
> > Grisha
> >
> > On Wed, 31 Mar 2004, John Mudd wrote:
> >
> > > What good is session.last_accessed() ?
> > >
> > > It seems to return the time that I created the session object or last
> > > read it from disk. Which tells me nothing of interest.
> > >
> > > I'd like to how long since the session was previously (if ever) saved to
> > > disk. Is there a way to get that?
> > >
> > > John
> > >
> > > _______________________________________________
> > > Mod_python mailing list
> > > Mod_python at modpython.org
> > > http://mailman.modpython.org/mailman/listinfo/mod_python
> > >
|