perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Gormley <>
Subject RE: Apache2::Cookie/APR::Request::Cookie
Date Sat, 09 Dec 2006 17:24:19 GMT

> Can I ask if there is something different when redirecting? It would
> appear the cookie isn't being sent in a redirect.

It should be fine setting cookies in a redirect as long as 
1) you're using $r->err_headers_out->add()
2) you're not doing an internal redirect

so, for instance, this sequence:
    $r->headers_out->set( Location => '');
    $r->err_headers_out->add( 'Set-Cookie', $cookie->as_string );
    return Apache2::Const::HTTP_SEE_OTHER;

> When logging in from the post form I see the "Set-Cookie" header being
> set but when I redirect them back to the URl they should be on I don't
> see the "Set-Cookie" header being set even though I pack up the cookie
> and set it again (just like in the previous POST request)

If you're setting the cookie header but you're not seeing it in the
headers from the server, then you're not setting it properly.  Are you
not overwriting the err_headers_out by using ->set instead of ->add?

> But does that even matter? A cookie isn't always set before its read
> in the same session, I might be looking for a cookie that was saved
> the last time you were on the site.

It only matter because it doesn't seem to be working...


View raw message