Michael ([EMAIL PROTECTED]) said something to this effect:
> Hmmmm.....
> 
> When I retrieve a cookie
> 
> %cookies = Apache::Cookie->fetch;
> 
> I get a hash that contains the name of the cookie as the key and a 
> scalar reference as the value. 
> Apache::Cookie=SCALAR(0xblah...)
> Can't seem to unravel it to get at the 
> value. Using
> 
> %xx = Apache::Cookie->parse($val);
> gives an apparently empty hash, yet retrieving the headers via 
> Apache::Table yields the correct results
> 
> Cookie=foo=bar
> 
> cook name val
>        foo  bar
> 
> 
> So what am I doing wrong with Apache::Cookie that keeps me from 
> returning the cookie value.

This should do it:

    my $ac      = Apache::Cookie->new($r);
    my $cookies = $ac->fetch;
    my %cookies = ();
    for (keys %{$cookies}) {
        $cookies{$_} = $cookies->{$_}->value;
    }

However, I always find it easier to fetch cookies like this:

    my $cookies = { map  { $1 => $2 if (/([^=]+)=(.*)/) }
                    grep !/^$/, split /;\s*/, $r->header_in('cookie') };
    $r->pnotes('cookies', $cookies);

No messing with objects or any of that stuff. Putting it into pnotes makes
the hashref accessible to other phases or subroutines easily (you only have
to pass $r). (That's why I use a hashref and not a hash, so I can just put
it directly into pnotes.)

(darren)

-- 
If you wish to drown, do not torture yourself with shallow water.

Reply via email to