use Apache;
use Apache::Cookie;
sub handler {
my $r = shift;
my $cookies = Apache::Cookie->new($r)->parse;
my %bar = $cookies->{foo}->value;
}
much simpler, no?
On Fri, 4 Feb 2000, Aaron Ross wrote:
> Hi!
> I'm trying to write an AccessHandler. I'm using CGI::Cookie to, you got it,
> create and parse Cookies. However, I'm getting an error that I don't totally
> understand. ( This is mod_perl related... just hold on. )
>
> If i call
> CGI::Cookie->parse($r->headers_in->get('Cookie'));
> I will get this error:
> Can't call method "register_cleanup" on an undefined value at
>/usr/lib/perl5/5.00503/CGI.pm line 262.
>
> Now that is on this line in the CGI.pm constructor:
>
> if ($MOD_PERL) {
> ---> Apache->request->register_cleanup(\&CGI::_reset_globals);
> undef $NPH;
> }
>
> Why does that fail? I'm running under mod_perl.. I mean this is failing when
> it is called from a PerlAccessHandler!
>
> My second question is why does CGI::Cookie create CGI object just to get a
> url! The call to CGI::new is becuase of this call in CGI::Cookie->new():
>
> # IE requires the path and domain to be present for some reason.
> $path = CGI::url(-absolute=>1) unless defined $path;
> # $path = "/" unless defined $path;
>
> removing the call to CGI::url fixes the error.
>
> So.. any advice or explanation?
>
> Aaron
>
>
>
- nick