You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Vishal Verma <vi...@epunjabis.com> on 2003/01/15 17:20:03 UTC
reading cookies from mod_perl HTTP request handlers
Hi,
I'm unable to access/read cookies from incoming HTTP requests using
mod_perl HTTP request handlers.Here's what my relevant apache config
section looks like
<Location />
PerlHeaderParserHandler MyModule::header_parse_handler
</Location>
My browser already has a cookie named 'foo' with value 'bar' with path &
expire times set appropriately. Here's what my browser GET request looks
like
GET /cgi-bin/login HTTP/1.1
Host: xxxxxx
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1)
Gecko/20021130
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1
Accept-Language: en-us, en;q=0.50
Accept-Encoding: gzip, deflate, compress;q=0.9
Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66
Keep-Alive: 300
Connection: keep-alive
Cookie: foo=bar
The last line confirms that the browser is sending the cookie.
But, I'm not able to see that cookie when I print $ENV{'HTTP_COOKIE'}
within in header_parse_handler. mod_perl docs say that that you can
examine request headers in the PerlHeaderParserHandler. Am I missing
something? Am I using a wrong handler? Please help.
thanks
-vish
Re: reading cookies from mod_perl HTTP request handlers
Posted by Vishal Verma <vi...@epunjabis.com>.
On Wed, 2003-01-15 at 14:24, Geoffrey Young wrote:
> if you want to force %ENV to be setup earlier, try calling
>
> $r->subprocess_env;
>
> in a void context before checking %ENV - it used to segfault for me, but the
> docs says it should work.
>
This worked for me! Thanks a million!
-vish
Re: reading cookies from mod_perl HTTP request handlers
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
>
> But, I'm not able to see that cookie when I print $ENV{'HTTP_COOKIE'}
> within in header_parse_handler.
%ENV is setup during the fixup phase, so it hasn't been populated yet.
> mod_perl docs say that that you can
> examine request headers in the PerlHeaderParserHandler.
yes, using something like $r->headers_in. you're actually better off using
Apache::Cookie, which is in the libapreq distribution on cpan.
if you want to force %ENV to be setup earlier, try calling
$r->subprocess_env;
in a void context before checking %ENV - it used to segfault for me, but the
docs says it should work.
HTH
--Geoff