At 14:31 18/04/2001, Gray, Josh wrote:
>How do you set two cookies at the same time using cgi.pm?  This is what i am
>using, but as i understand it, when it writes the cookie it writes the html
>header, how do i do two at the same time?

You just need to list the cookies one after another.  I used the code below 
to set any number of cookies depending on the number of vars in a list.

&MAKECOOKIES;

sub MAKECOOKIES {
         foreach my $NAME (@OTOVARS) {
                 $COOKIES .= &BAKECOOKIE("$NAME", "$VARHASH{$NAME}", "", 
"$SCRIPTPATH");
         }
}

sub BAKECOOKIE {
         my $c;
         my ($NAME, $VALUE, $EXPIRY, $PATH) = @_;
         if ($EXPIRY ne "") {
                 $c = new CGI::Cookie(-name    =>  "$NAME",
                                         -expires =>  "$EXPIRY",
                                         -value   =>  "$VALUE",
                                         -path    =>  "$PATH"
                 );
         }
         else {
                 $c = new CGI::Cookie(-name    =>  "$NAME",
                                         -value   =>  "$VALUE",
                                         -path    =>  "$PATH"
                 );
         }
         $c = "Set-Cookie: $c\n";
         return ($c);
}

All it does, is loop around the code that creates the cookie,but appends 
them all onto one variable which is output at the end.

HTH

Roland

-- 
Roland Corbet
Systems Administrator & Developer
Psyche Solutions Limited
Chester Road
Cradley Heath
West Midlands
B64 6AB

Tel:    + 44 (0)1384 414183 Ext. 4412
Fax:    + 44 (0)1384 414111
Email:  [EMAIL PROTECTED]
WWW:   http://www.psyche.net.uk

_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

Reply via email to