[mod_python] Problem setting cookie and then redirecting

Gregory Trubetskoy grisha at modpython.org
Tue Oct 17 16:30:12 EST 2000

Do this:

req.headers_out['location'] = 'http://localhost/index.html'
req.status = apache.HTTP_MOVED_TEMPORARILY
return apache.OK

The last line doesn't really matter since req.status is set and headers
already went out.

On Tue, 17 Oct 2000, Geoff Cadien wrote:

> >From a PythonHandler I'm trying to set a cookie and then do a redirect
> and it is not working.  I'm doing:
> req.headers_out['Set-Cookie']='key=value'
> req.headers_out['location'] = 'http://localhost/index.html'
> The problem seems to be that if I don't do req.send_http_header() the
> Set-Cookie doesn't get sent so the cookie doesn't get set.  If I do call
> req.send_http_header() the cookie does get set but it seems as though
> two sets of headers are sent and the response code is 200.  Any ideas?
> Geoff Cadien
> geoff at infostreet.com
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://www.modpython.org/mailman/listinfo/mod_python

More information about the Mod_python mailing list