Re: I'm missing something in Apache::Cookie (fwd)

2000-09-17 Thread Joe Schaefer

"Thomas S. Brettin" <[EMAIL PROTECTED]> writes:

> from the looks of the code you guys posted, I would guess that
> Cookie->fetch returns a hash reference, not a hash.  Could this be the
> problem?
> 

It can return either a hash or a hash reference, depending on whether or not 
you wantarray.  The problem many people encounter is that the values in the
returned hash(ref) are Apache::Cookie OBJECTS, not simply value of the
cookie.  There's more to a cookie than just it's value. 
I think it goes something like this.

%cookies = Apache::Cookie->fetch;

print ref \%cookies; # prints HASH ??
print ref $cookies{'SESSION'}; # prints Apache::Cookie ??
print $cookies{'SESSION'}->value; # prints the value of SESSION cookie

RTFM to be sure, or run it and see what you get!

-- 
Joe Schaefer
[EMAIL PROTECTED]

SunStar Systems, Inc.



Re: I'm missing something in Apache::Cookie (fwd)

2000-09-15 Thread Thomas S. Brettin


from the looks of the code you guys posted, I would guess that
Cookie->fetch returns a hash reference, not a hash.  Could this be the
problem?


Thomas S. Brettin
Staff Member
Bioscience Division, MS-M888
Los Alamos National Laboratory
Los Alamos, NM 87545
505-665-3334

On Fri, 15 Sep 2000, Chris Winters wrote:

> * Michael ([EMAIL PROTECTED]) [000915 17:29]:
> > H.
> > 
> > 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.
> > 
> > Michael
> 
> The following seems to work for me in nabbing all the cookies sent and
> putting them into a hashref $cookies
> 
>my $cookies = {};
>my $cookie_info = Apache::Cookie->fetch;
>foreach my $name ( keys %{ $cookie_info } ) {
>  $cookies->{ $name } = $cookie_info->{ $name }->value;
>}
> 
> HTH
> 
> Chris
> 
> -- 
> Chris Winters
> Senior Internet Developerintes.net
> [EMAIL PROTECTED]   http://www.intes.net/
> Integrated hardware/software solutions to make the Internet work for you.
>