httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rasmus Lerdorf <ras...@lerdorf.on.ca>
Subject Re: general/2615: Set-Cookie not sent with Redirect response
Date Wed, 23 Dec 1998 00:46:37 GMT
> >   ap_table_set(r->headers_out, "location","http://www.apache.org");
> >   r->status = REDIRECT;
> 
> This doesn't set the cookie if it was only added to headers_out, because
> according to an email I have lying around from marcs when I encountered
> this issue writing my own module:
> 
>    I think the current semantics are:
> 
>    headers_out        headers sent only with 200..299 and 304 responses
>    err_headers_out    headers sent with all responses
> 
> Thus the cookie is not set on a 301 or 302 response code.  So, for us
> the workaround was to use err_headers_out, a la:
> 
>     ap_table_addn(r->err_headers_out, "Set-Cookie", cookie);
> 
> Not obvious to the uninitiated though.

Hrm..  Are you sure about that?  I use the normal r->headers_out for both
my cookies and my redirect and it works fine.  The code looks something
like this (with all sorts of gunk removed):

   table_set(r->headers_out, "Location", location_str);
   r->status = REDIRECT;
   table_add(r->headers_out, "Set-Cookie", cookie_str);
   send_http_header(r);

And when I try it I get:

Connected to www.lerdorf.on.ca.
Escape character is '^]'.
GET /cr.html HTTP/1.1
Host: www.lerdorf.on.ca

HTTP/1.1 302 Found
Date: Wed, 23 Dec 1998 00:35:16 GMT
Server: Apache/1.3.4-dev (Unix) PHP/3.0.6
Location: http://www.apache.org
Set-Cookie: TestCookie=Green+slimy+things
Transfer-Encoding: chunked
Content-Type: text/html


So it definitely gets sent on a 302.  That brings up another question.
REDIRECT is defined to be HTTP_MOVED_TEMPORARILY which is 302.  How is
that different from HTTP_TEMPORARY_REDIRECT 307?  I never really
understood that, but didn't care because it seemed to work.

-Rasmus


Mime
View raw message