[mod_python] Problem setting cookie and then redirecting

Geoff Cadien geoff at infostreet.com
Tue Oct 17 13:35:29 EST 2000


That did the trick.  Thanks!

-geoff

Gregory Trubetskoy wrote:
> 
> Do this:
> 
> req.headers_out['Set-Cookie']='key=value'
> req.headers_out['location'] = 'http://localhost/index.html'
> req.status = apache.HTTP_MOVED_TEMPORARILY
> req.send_http_header()
> return apache.OK
> 
> The last line doesn't really matter since req.status is set and headers
> already went out.
> 
> Grisha
> 
> 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'
> > return apache.HTTP_MOVED_TEMPORARILY
> >
> > 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