[mod_python] Cookies and Redirects

Graham Dumpleton graham.dumpleton at gmail.com
Wed Mar 5 16:22:25 EST 2008


On 06/03/2008, Kathryn Van Stone <kvs at acm.org> wrote:
>
> 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 page".
>
> Specifically: the cookies header is set, the location header is set, the
> status is set to 303, and 303 is returned from the PythonHandler.

Technically you shouldn't be doing both setting status to 303 and
returning status 303.

Post your actual minimal code for the handler which shows what you are
doing. Trying to describe it is not enough as you could be doing
something trivially wrong that you haven't mentioned and we wouldn't
know.

Graham

> 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).
> _______________________________________________
>  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