RE: Apache::Cookie

2003-06-04 Thread cap
it works just fine in my app, and 'just fine' maybe all that i need.  do you
have a better solution, or are you just pointing out the error?



-Original Message-
From: Stas Bekman [mailto:[EMAIL PROTECTED]
Sent: Monday, June 02, 2003 10:08 PM
To: [EMAIL PROTECTED]
Cc: Perrin Harkins; modperl
Subject: Re: Apache::Cookie


cap wrote:
 Well, here's what I have to do to get direct access to values from the
 original cookie hash:

 my $cookies = Apache::Cookie-fetch;
 my %hash = defined $cookies-{'session'} ? $cookies-{'session'}-value :
 undef;

 Strange. Thanks for the lead.

That's a bogus code. Obviously you are running without warnings
mode on. Add:

use warnings;

and you will see why it is bogus. Perhaps your cookie was always
valid so you
didn't notice it. Howerer:

perl -lwe '%h = undef'
Name main::h used only once: possible typo at -e line 1.
Odd number of elements in hash assignment at -e line 1.
Use of uninitialized value in list assignment at -e line 1.




-Original Message-
From: Perrin Harkins [mailto:[EMAIL PROTECTED]
Sent: Monday, June 02, 2003 2:41 PM
To: [EMAIL PROTECTED]
Cc: modperl
Subject: Re: Apache::Cookie


On Mon, 2003-06-02 at 09:05, cap wrote:

i have an application that uses CGI and sets the cookie values

as a hashref.

im then attempting to retreive the values with Apache::Cookie with:

$cookies = Apache::Cookie-fetch;

$ccokies is a hashref so i should be able to get the individual

values with:

$cookies-{uid};

right?  however, this doesn't appear to work.

I see the problem.  There is mistake in the Apache::Cookie
documentation, but the correct way to do this is shown in the mod_perl
guide:
http://perl.apache.org/docs/1.0/guide/porting.html#Converting_to_us
e_Apache_Perl_Modules

Change your last line to this:

my $uid = defined $cookies-{'uid'} ? $cookies-{'uid'}-value() :
undef;

- Perrin




--


__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com





RE: Apache::Cookie

2003-06-04 Thread cap
Okay, I'm obviously no expert but I see a problem ... I think? :

  my $cookie = Apache::Cookie-fetch;
  my $ref_cookie = ref $cookie;

returns 'HASH'

but

  my $session = $cookies-{'session'}-value;
  my $type = ref @session;

doesn't return anything, '' or (undef?).  strange?

However:

  my @session = $cookies-{'session'}-value;

returns the (almost) desired result as pairs and as they were originally
inserted from the standard CGI cookie.  so i thought it was acceptable to
convert to a hash, knowing the list values are in pairs:

my %hash = $cookies-{'session'}-value;

will probably throw a warning or even an error without the defined
statement, but it gets past the immediate issue.

kirk







-Original Message-
From: Perrin Harkins [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 03, 2003 10:57 AM
To: [EMAIL PROTECTED]
Cc: Stas Bekman; modperl
Subject: RE: Apache::Cookie


On Tue, 2003-06-03 at 13:08, cap wrote:
 it works just fine in my app, and 'just fine' maybe all that i need.

The point is, it shouldn't work.  You should not be getting a hash.
What should work is this:

my $session = defined $cookies-{'session'} ?
$cookies-{'session'}-value : undef;

The larger issue is fixing the Apache::Cookie docs.  I would attempt to
patch it if I understood what it's doing.  Does anyone know what the API
is returning when you call fetch()?  An Apache::Table?  Some other kind
of object?  It looks pretty bizarre to me, and it certainly isn't doing
what the docs show.

- Perrin




Apache::Cookie

2003-06-03 Thread cap
i have an application that uses CGI and sets the cookie values as a hashref.
im then attempting to retreive the values with Apache::Cookie with:

$cookies = Apache::Cookie-fetch;

$ccokies is a hashref so i should be able to get the individual values with:

$cookies-{uid};

right?  however, this doesn't appear to work.




RE: Apache::Cookie

2003-06-03 Thread cap
Yes, but:

use Apache::Cookie;

my $cookie = Apache::Cookie-fetch;
my @values = $cookie-value;

returns errors.




-Original Message-
From: Jason Galea [mailto:[EMAIL PROTECTED]
Sent: Monday, June 02, 2003 5:56 AM
To: [EMAIL PROTECTED]
Cc: modperl
Subject: Re: Apache::Cookie


Have you consulted the documentation?

http://search.cpan.org/author/JIMW/libapreq-1.1/Cookie/Cookie.pm#value


cap wrote:
 i have an application that uses CGI and sets the cookie values 
as a hashref.
 im then attempting to retreive the values with Apache::Cookie with:
 
 $cookies = Apache::Cookie-fetch;
 
 $ccokies is a hashref so i should be able to get the individual 
values with:
 
 $cookies-{uid};
 
 right?  however, this doesn't appear to work.
 
 
 
 




RE: Apache::Cookie

2003-06-03 Thread cap
Well, here's what I have to do to get direct access to values from the
original cookie hash:

my $cookies = Apache::Cookie-fetch;
my %hash = defined $cookies-{'session'} ? $cookies-{'session'}-value :
undef;

Strange. Thanks for the lead.




-Original Message-
From: Perrin Harkins [mailto:[EMAIL PROTECTED]
Sent: Monday, June 02, 2003 2:41 PM
To: [EMAIL PROTECTED]
Cc: modperl
Subject: Re: Apache::Cookie


On Mon, 2003-06-02 at 09:05, cap wrote:
 i have an application that uses CGI and sets the cookie values
as a hashref.
 im then attempting to retreive the values with Apache::Cookie with:

 $cookies = Apache::Cookie-fetch;

 $ccokies is a hashref so i should be able to get the individual
values with:

 $cookies-{uid};

 right?  however, this doesn't appear to work.

I see the problem.  There is mistake in the Apache::Cookie
documentation, but the correct way to do this is shown in the mod_perl
guide:
http://perl.apache.org/docs/1.0/guide/porting.html#Converting_to_us
e_Apache_Perl_Modules

Change your last line to this:

my $uid = defined $cookies-{'uid'} ? $cookies-{'uid'}-value() :
undef;

- Perrin