Jaspersan has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use CGI; use strict; my $wm = CGI::new(); print $wm->header(); my ($usr,$pw); if ($ENV{'HTTP_COOKIE'}) { $usr = $wm->cookie('user'); $pw = $wm->cookie('pass'); } else { $usr = $wm->param('usr'); $pw = $wm->param('pw'); &set_cookie($usr,$pw,$wm); } print<<LOSER; <html> <body> LOSER if (length($usr) > 0 && length($pw) > 0) { #check login. if it fails, display login form (removed because of +length) #note: right here it would print "Username: $user Password: $pass" #which it should print the cookie values for 'user' and 'pass'. print "Username: $usr Password: $pw<br>\n"; } else { #login form (removed because of length) } print<<END; </body> </html> END sub set_cookie { my $user = shift; my $pass = shift; if (defined($user) && defined($pass)) { # we set cookie # method 1 print "$user asfsfafaf $pass<br>\n"; print "Set-Cookie: user=$user;expires=+1hr\n"; print "Set-Cookie: pass=$pass;expires=+1hr\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Receiving Cookie Values
by dingus (Friar) on Dec 04, 2002 at 15:48 UTC | |
by Jaspersan (Beadle) on Dec 04, 2002 at 21:05 UTC | |
by dingus (Friar) on Dec 05, 2002 at 08:31 UTC | |
by Jaspersan (Beadle) on Dec 09, 2002 at 13:43 UTC | |
by Jaspersan (Beadle) on Dec 05, 2002 at 13:40 UTC |