[mod_python] Cookies and redirect...

David Fraser davidf at sjsoft.com
Thu Aug 14 15:54:39 EST 2003


I came across the following problem and wondered if there was a workaround.
Basically I want to set a cookie in a certain directory, and at the same 
time issue a Redirect to another place.
So I wanted to do:
  req.headers_out.add('Set-Cookie', morsel.OutputString())
  req.headers_out.add('Location:', location)

However, I found that as soon as I return the HTTP_MOVED_TEMPORARILY, 
the Set-Cookie string seems to be removed from the headers going to the 
client (this was tested by using the livehttpheaders extension to Firebird).
I couldn't work out where in the code that was happening but suspect 
that it is standard Apache behaviour.
Is this because I'm not supposed to be allowed to do this, or is it odd?

(I have a workaround of having a page with a meta http-equiv="refresh", 
but wondered if there is a way to get it working as would like...)


More information about the Mod_python mailing list