Thanks for the reply Clinton, I was just using the same request obj from the
handler, guess that was wrong :)
I tried your read example and now I don't get anything at all (even though I
can see the cookie on the machine)
my $req = APR::Request::Apache2->handle( $r );
my $jar = $req->jar;
my %cookies;
foreach my $key ( keys %$jar ) {
print "Key is $key and value is " . $jar->get($key);
$cookies{$key} = $jar->get($key);
}
And if I do just this
my $req = APR::Request::Apache2->handle( $r );
my $jar = $req->jar;
my $cookie = $jar->get('ISMH_SESSION_ID');
I get the error of "Can't call method "get" on an undefined value"
If it matters, I load the modules in my startup.pl
use Apache2::Request ();
use Apache2::RequestRec ();
use Apache2::Cookie ();
use Apache2::Const -compile => qw(REDIRECT);
use Apache2::Const -compile => qw(OK);
use APR::Table ();
use APR::Request ();
use APR::Request::Cookie ();
Am I doing anything that is clearly wrong?
Thanks
-Chris
________________________________
From: Clinton Gormley [mailto:[EMAIL PROTECTED]
Sent: Sat 12/9/2006 8:53 AM
To: cfaust-dougot
Cc: [email protected]
Subject: Re: Apache2::Cookie/APR::Request::Cookie
>
> The man page then says to use APR::Request::Cookie I should:
> my $jar = $r->jar;
> my $cookie = $jar->get("ISMH_SESSION_ID");
What is $r in this case? It should be an APR::Request::Apache2 or
(APR::Request::CGI I think) handle.
So, where $r is an Apache2::RequestRec object:
To set:
-------
my $cookie = APR::Request::Cookie->new(
$r->pool,
expires => '+7d',
value => 'value',
name => 'name'
) or die;
$r->err_headers_out->add( 'Set-Cookie', $cookie->as_string );
To read:
--------
my $req = APR::Request::Apache2->handle( $r );
my $jar = $req->jar;
my %cookies;
foreach my $key ( keys %$jar ) {
$cookies{$key} = $jar->get($key);
}
clint