[mod_python] Cookies and Redirects

Kathryn Van Stone kvs at acm.org
Wed Mar 5 14:28:19 EST 2008

Our web application has a login page that uses a POST.  Upon  
receiving the POST, we set some cookies on the request object by  
using mod_python's Cookie.add_cookie(request, c).  Then we set a  
Location header and return a 303 to redirect the user to their "home  

Specifically: the cookies header is set, the location header is set,  
the status is set to 303, and 303 is returned from the PythonHandler.  
Content is not set. We have no later handlers.

Unfortunately, the cookie headers do not seem to survive ---  they  
seem to be there in log output from the code immediately prior to  
returning, but if we examine the 303 response the client actually  
sees the cookie headers are gone and only the Location header  
remains.  (In an earlier iteration we returned a regular 200 with an  
HTML page that did a META redirect in the <head>; that worked fine.)

Any ideas?  Is Apache or mod_python eating the cookies at some lower  
level?  Is there a "typical" way people do this sort of operation?

Kathy Van Stone (for a co-worker).
kvs at acm.org

Note: we haven't yet tried a bare handler that does just the above  
steps.  If people here say "hmm, that should have worked" that will  
be our next step.  On the other hand, if there is a rule about  
redirects and cookies (or if we should be returning something besides  
a 303 from the handler), that would be helpful to know before we  
spend time trying to get this to work.

(Current workaround is to go back to the HTML page with a meta).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20080305/7ef9f555/attachment.html

More information about the Mod_python mailing list