#!perl BEGIN { $| = 1; open (STDERR, ">&STDOUT"); print qq~Content-type: text/html\n\n~; } use warnings; use CGI qw(:standard); use CGI::Cookie; use CGI; $user = "test"; $pws = "123456"; $query = CGI->new(); if ($query->param('user') eq ""){ print "Enter your User name."; exit; } if ($query->param('pws') eq ""){ print "Enter your password."; exit; } if (($query->param('user') eq "$user") && ($query->param('pws') eq "$pws")) { $query = CGI->new(); my %cookie = CGI::Cookie->fetch; if (exists $cookie{'$user'}) { print header, start_html('got cookie'), p('found the cookie: ' . $cookie{$user}->value), end_html, ; exit; } else { my $cookie = CGI::Cookie->new(-name=>$user,-value=>$pws,-expires=>'+23h'); print header(-cookie=>$cookie), start_html('need cookie'), p('setting cookie, please reload'), end_html, ; exit; } } print "Your User name / Password it's not good.
"; exit;