You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Sam Tregar <sa...@tregar.com> on 2006/02/15 20:11:57 UTC
Why is err_header_out needed to set cookies when redirecting?
Hello all. Check out this bug:
my $r = Apache->request;
$r->header_out(Set-Cookie => '...cookie here...' );
$r->header_out(Location => '...url here...');
return REDIRECT;
Now, we all know that second line has to be err_header_out not
header_out, or Apache will silently ignore the Set-Cookie directive.
I knew it as soon as I saw it, although I couldn't explain why and
thus didn't trust my intuition. I looked through the list archives
and the guide without finding an explaination that made sense.
Would anyone mind explaining this to me?
Thanks,
-sam
PS: This is Apache v1.3.33 with mod_perl v1.29, in case it matters.
Re: Why is err_header_out needed to set cookies when redirecting?
Posted by Sam Tregar <sa...@tregar.com>.
On Wed, 15 Feb 2006, Michael Peters wrote:
>> Now, we all know that second line has to be err_header_out not
>> header_out, or Apache will silently ignore the Set-Cookie directive.
>> I knew it as soon as I saw it, although I couldn't explain why and
>> thus didn't trust my intuition. I looked through the list archives
>> and the guide without finding an explaination that made sense.
>>
>> Would anyone mind explaining this to me?
>
> Anything that does not return an OK is considered an 'error', so it
> won't send the normal header_out() stuff.
How does Location get through then? It's set using header_out() and
works...
-sam
Re: Why is err_header_out needed to set cookies when redirecting?
Posted by Michael Peters <mp...@plusthree.com>.
Sam Tregar wrote:
> Hello all. Check out this bug:
>
> my $r = Apache->request;
> $r->header_out(Set-Cookie => '...cookie here...' );
> $r->header_out(Location => '...url here...');
> return REDIRECT;
>
> Now, we all know that second line has to be err_header_out not
> header_out, or Apache will silently ignore the Set-Cookie directive.
> I knew it as soon as I saw it, although I couldn't explain why and
> thus didn't trust my intuition. I looked through the list archives
> and the guide without finding an explaination that made sense.
>
> Would anyone mind explaining this to me?
Anything that does not return an OK is considered an 'error', so it won't send
the normal header_out() stuff.
--
Michael Peters
Developer
Plus Three, LP
Re: Why is err_header_out needed to set cookies when redirecting?
Posted by Sam Tregar <sa...@tregar.com>.
On Wed, 15 Feb 2006, Geoffrey Young wrote:
> in short, because anything other than 200 is considered an error. so
> REDIRECT (302) forces apache to use the err_headers_out table instead of the
> headers_out table.
>
> why does Location work in headers_out, then, you ask? well, it's an
> exception to the rule - see http_protocol.c :)
Thanks Geoff. I guess I don't feel so bad that it doesn't make sense
then!
-sam
Re: Why is err_header_out needed to set cookies when redirecting?
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Sam Tregar wrote:
> Hello all. Check out this bug:
>
> my $r = Apache->request;
> $r->header_out(Set-Cookie => '...cookie here...' );
> $r->header_out(Location => '...url here...');
> return REDIRECT;
>
> Now, we all know that second line has to be err_header_out not
> header_out, or Apache will silently ignore the Set-Cookie directive.
> I knew it as soon as I saw it, although I couldn't explain why and
> thus didn't trust my intuition. I looked through the list archives
> and the guide without finding an explaination that made sense.
>
> Would anyone mind explaining this to me?
in short, because anything other than 200 is considered an error. so
REDIRECT (302) forces apache to use the err_headers_out table instead of the
headers_out table.
why does Location work in headers_out, then, you ask? well, it's an
exception to the rule - see http_protocol.c :)
--Geoff