[mod_python] Session-Handling mod_publisher

Graham Dumpleton grahamd at dscpl.com.au
Sat Nov 11 22:00:32 EST 2006

On 10/11/2006, at 8:53 PM, Gregor Kling wrote:

> Hello,
> Once upon the time I used hidden fields for session tracking.
> Now I want to use Cookies in combination with the FileSession class  
> for
> that.
> The problem is how to assure the cookie was successfully added by the
> browser.
> Is there an idiom ?
> Can I do something like that:
> def start(req):
> c = Cookie.Cookie('foobar',expires='')
> Cookie.add_cookie(req, c)
> t = get_cookies(req,Cookie,foobar)
> if t:
> go_on
> else:
> leave

Why use cookies directly? Why not use the Session class instead as
underneath it does the cookie stuff for you. You also should not use
FileSession directly either. Always use Session.Session() to get the
reference to the session object and use the PythonOption to specify
the type of session to use.

BTW, if you dump out req.headers_out you can verify that the output
headers are setup correctly with the cookie stuff.


More information about the Mod_python mailing list