I use this: use Apache2::Cookie;
sub get_cookies($) { my $r = shift; my $jar = Apache2::Cookie::Jar->new($r); my $cookies = $jar->cookies(); return $cookies; } and call any cookie with $cookies->{key}->value if $cookies->{key}->value; please note that you need a new libapreq2, I had huge issues with 2.06 and had to switch to the svn trunk to get it to work properly. not sure if those fixes already made it to the current devel package, though, but it might be wise to upgrade if you are unsure. (one of the probs was that it would segfault if you tried to set an empty cookie). Enno > c1 => 'v1', > c2 => 'v2', > > I expect @names to contain ( "c1", "c2" ), but instead > @names contains ( "c1", "c1=v1", "c2", "c2=v2" ) > > The following code has the above problem: > > my $jar = Apache2::Cookie::Jar->new( $r ); > my @names = $jar->cookies; > for my $name ( @names ) { > my $cookie = $jar->cookies( $name ); > my @vals = $cookie->value(); > print "cookie: $name values: @vals\n"; > } > > > Instead, I have ended up with: > > my $jar = Apache2::Cookie::Jar->new( $r )->cookies; > my @cookies = values %$jar; > for my $cookie ( @cookies ) { > my $token = $cookie->name(); > my @vals = $cookie->value(); > print "cookie: $token value: @vals\n"; > } > > > Is there a better way? I couldn't get this to work: > > my @cookies = values / > %{ scalar Apache2::Cookie::Jar->new( $r )->cookies }; > > - seems that the Jar class is trying much to hard to be clever? Or maybe > I'm just being dumb? > > Thoughts appreciated, > > Jeff > > > > >