Folks,
I am finding it hard to correctly interpret the Apache2::Cookie
documentation: The docs say:
@names = $j->cookies(); # all cookie names
When I do this, for the following cookies:
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