Casteele/ShadowLord wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi, > > I don't know perl well enough to figure this out, but there's prolly a super > simple answer.. I've got a perl CGI script using CGI.pm: > > [code] > use CGI; > > my $q, $c; > > $q = new CGI; > $c{'old'} = fetch CGI::Cookie; > > <does some manipulations on the cookies> > > print $q->header( > -type => 'text/html', > -charset => 'iso-8859-1', > -expires => 'now', > -cookie => $c{'old'} > ); > [/code] > > Of course, that code does not work.. the line sent ends up looking like: > Set-Cookie: HASH(0x...) > > I understand what the problem is.. The variable is a hashref.. The problem > is, I can't figure out what exactly the $q->header expects for the -cookie > line, or how to coerce the cookies data into what's expected. The CGI.pm > docs seem to indicate it expects either a CGI::Cookie object or an arrayref > of CGI:Cookie objects (-cookie => [ $cookie1, $cookie2 ]), but I can't do > that > as I don't know ahead of time how many cookies, or cookie variables I'll > need. > > I even tried iterating thru each cookie, pushing it onto array to pass on, > but > that lead to even weirder results and errors.. The only thing I haven't done > (and want to avoid--perl programmers are supposed to be LAZY, right? ;-P) > is manually walking the cookies and re-creating each one from scratch. > > What should I do? I've run outta things to try..
#!/usr/bin/perl -- 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__ _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs