[mod_python] Save cookie and redirect

Manfred Stienstra manfred.stienstra at dwerg.net
Thu Jul 3 13:57:04 EST 2003


On Thursday 03 July 2003 13:39, Alexiev Nikolay wrote:
> I try to set cookie and redirect with one response. Redirect works fine but
> cookie dosn't exist. What can I do?
>
>
> HTTP_MOVED_PERMANENTLY = 301
> req.headers_out.add('Set-Cookie', cookies.output(header='',
> sep='\r\nSet-Cookie:'))
> req.headers_out.add('Location', redirect)
> req.status = HTTP_MOVED_PERMANENTLY

First set the cookie and after that redirect. If it's a login page you could 
display a page saying something like 'successfully logged in' (setting the 
cookie) and after that (5 secs or something) you redirect.

Manfred



More information about the Mod_python mailing list