El Mar 12 Mar 2002 11:23, Axel Andersson escribió: > Hello, > I'm having trouble with both setting a cookie and redirecting the user to > another page at the same time. It would appear the cookie is only sent > when a normal header is sent by server. > > If I do the following (having baked the cookie first), where $r is the > Apache->request() object: > > $r->content_type("text/html; charset=iso-8859-1"); > $r->send_http_header(); > > I get this header: > > Connection: close > Date: Tue, 12 Mar 2002 10:39:05 GMT > Server: Apache/1.3.23 (Unix) mod_perl/1.26 > Content-Type: text/html; charset=iso-8859-1 > Client-Date: Tue, 12 Mar 2002 10:39:05 GMT > Client-Response-Num: 1 > Client-Transfer-Encoding: chunked > Set-Cookie: user=12::7c786c222596437b; domain=animanga.nu; path=/; > expires=Wed, > 12-Mar-2003 10:39:05 GMT > > Very nice and all, with cookie set. However, doing: > > $r->method_number(M_GET); > $r->method("GET"); > $r->headers_in->unset("Content-length"); > $r->headers_out->add("Location" => "/users.pl"); > $r->status(REDIRECT); > $r->send_http_header(); > > Which I gather is the normal way to redirect a user, I get this header: > > Connection: close > Date: Tue, 12 Mar 2002 10:38:36 GMT > Server: Apache/1.3.23 (Unix) mod_perl/1.26 > Content-Type: text/html; charset=iso-8859-1 > Client-Date: Tue, 12 Mar 2002 10:38:36 GMT > Client-Response-Num: 1 > Client-Transfer-Encoding: chunked > > Right, no Set-cookie there. So what's up? How do I redirect a browser, > and set a cookie at the same time? > > Thanks in advance, > Axel Andersson
Have you tried printing the headers_out hashref after sending the http header to see if the cookie is there ?. my $headers_out = $r->headers_out; foreach (keys %$headers_out) { warn "$_=$headers_out->{$_}"; } Hans