perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John ORourke <john-modp...@o-rourke.org>
Subject Re: Apache2::Cookie/APR::Request::Cookie
Date Sat, 09 Dec 2006 15:48:53 GMT
cfaust-dougot wrote:
> I've tried both Apache2::Cookie and APR::Request::Cookie (from the 
> posts I read I got the impression it was better to use 
> ARP::Request::Cookie then Apache2::Cookie).
Definitely.  You also need to read the man pages, but I've saved you the 
trouble...

> $r->err_headers_out->add('Set-Cookie' => $packed_cookie->as_string);
Good - you could also $packed_cookie->bake($r);

> The man page then says to use APR::Request::Cookie I should:
> my $jar = $r->jar;
> my $cookie = $jar->get("ISMH_SESSION_ID");
jar() returns undef if the browser sent no Cookie header - hence "can't 
call get method on undefined".
It's also tied to a hash - $$jar{ISMH_SESSION_ID}

$cookie is an object, which supports the "" overload, but I struggled to 
use that.  The bit you're missing goes after that:

$ismh_session_id = $cookie->value();

Freeze and Thaw are only needed if the cookie value is a data structure 
like a hash, not needed in this case.

hth,
John


Mime
View raw message