-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

That wasn't quite what I was looking for.. (It prolly didn't help I trimmed 
down the code 
snippet considerably.. the actual code is several pages long..) But someone 
else answered 
me on another list. Posting it here for the the benefit of anyone else having 
trouble, or 
maybe future refernce..

The problem is that 'fetch CGI::Cookie' returns a hashref where each key was 
the cookie 
name, and each value was a cookie object. What I wanted, was just an array of 
the cookie 
objects (the hash values).. made more complicated because I had to set the new 
cookie 
values in the header, while still using the old cookie values when generating 
the HTML 
page. At any rate, the solution was to use this as the cookie line..

[code]
...
        -cookie => [ values(%{$c{'new'}}) ]
...
[/code]

Yes, I "D'oh! *smacks head*" on that one. On the plus side, you did remind me 
to use 
CGI::Carp, which helped me find another little error I had not even noticed 
'til now! ;-)

On 26 Dec 2006 at 17:53, $Bill Luebkert wrote:

> use strict;
> use warnings;
> use CGI;
> use CGI::Cookie;
> use CGI::Carp qw(carpout fatalsToBrowser);
> 
> my $cgi = new CGI;
> my $wasset = $cgi->cookie('log_in');  # using the log_in cookie here
> 
> if ($wasset) {        # if cookie was set
>  print $cgi->header(-type => 'text/html', -charset => 'iso-8859-1',
>    -expires => 'now');
>  print "<BR>log_in cookie set to '$wasset'\n";
> } else {      # else not set, set it
>  my $user = 'user';
>  my $pass = 'pass';
>  my $value = "$user-$pass";
>  my $cookie = $cgi->cookie(-name => 'log_in', -value => $value);
>  print $cgi->header(-type => 'text/html', -charset => 'iso-8859-1',
>    -expires => 'now', -cookie => $cookie);
>  print "<BR>log_in cookie not set - setting now\n";
> }
> 
> __END__


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3rc1 (MingW32)

iD8DBQFFkfM9tSHnwqiHnD4RAgsAAJ4oXnml1cjeiyKLvS6R9j4UrO3ptACfV/Wq
4n9T0MSWoFE2yhNqzRoRPKM=
=RS+x
-----END PGP SIGNATURE-----
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to