[mod_python] Session variables

John Mudd mudd at vex.net
Wed Apr 14 14:46:34 EST 2004


Unfortunately I was wrong in some respects.  Here's Grisha's response.

John


---


The cookie is set in the __init__ method of the session object, so
saving
the session and the cookie are not related.

Also keep in mind that the cookie is set only once - when the session is
new. After that there is no need for it, it's the client who has to send
the cookie to the server every time, the server does not need to
"return"
it. So if your session persists over 100 HTTP requests, 1 will have a
cookie header, and 99 will not.

Grisha





On Wed, 2004-04-14 at 13:23, Gustavo Córdova Avila wrote:
> Ach, this is beautiful, concise, clear, and to the point.
> 
> Thankyou so much!!
> 
> -gustavo
> 
> John Mudd wrote:
> 
> >I think the session object is auto loaded (if one already exists).  You
> >can request a session for a specific sid but I don't know why.  The sid
> >is auto saved in a cookie for you.
> >
> >	session = Session.Session(req, None, secretKey)
> >
> >
> >If you saved a session before for this same client, and it hasn't
> >expired yet. you'll get the same session back.  If it's a mew client or
> >te session expired you'll get a new (blank) session.  Use is_new() to
> >test.
> >
> >	if session.is_new():
> >	
> >
> >Once you have a session object you can store stuff in it.  Like a
> >dictionary.  You can also set (and later reset) a timeout.
> >
> >    session['login'] = login
> >    session['passwd'] = passwd
> >    session['page'] = nextPage
> >    session['loginCount'] = loginCount
> >
> >
> >
> >And it seems that a "pysid" cookie is auto generated when you save the
> >session object.  
> >
> >	session.save()
> >
> >
> >Pretty cool.  Now if there is just an automatic way to tell if a new
> >session is the result of an old session expiring...
> >
> >John
> >
> >
> >On Thu, 2004-04-01 at 11:58, jakob at simon-gaarde.dk wrote:
> >  
> >
> >>Hello.
> >>I can see that you can save and load session values from mod_python 3.1,
> >>but unfortunately I don't understand how this works. Could someone
> >>elabourate with an example please?
> >>
> >>Best regards Jakob Simon-Gaarde
> >>_______________________________________________
> >>Mod_python mailing list
> >>Mod_python at modpython.org
> >>http://mailman.modpython.org/mailman/listinfo/mod_python
> >>    
> >>
> >
> >_______________________________________________
> >Mod_python mailing list
> >Mod_python at modpython.org
> >http://mailman.modpython.org/mailman/listinfo/mod_python
> >
> >
> >  
> >



More information about the Mod_python mailing list