#!/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 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
\n"; } else { #login form (removed because of length) } print< END sub set_cookie { my $user = shift; my $pass = shift; if (defined($user) && defined($pass)) { # we set cookie # method 1 print "$user asfsfafaf $pass
\n"; print "Set-Cookie: user=$user;expires=+1hr\n"; print "Set-Cookie: pass=$pass;expires=+1hr\n"; } }