#!/opt/bin/perl
use CGI ':standard';
$query = new CGI();
$sweet = $query->cookie(-name=>'answers');#check for a cookie
#Get current Time
$current_time = localtime;
#does cookie exist
if ($sweet) {
print "Content-type: text/html\n\n";
#create html page info
print $query->start_html(-title=>"Session"),
$query->h1("cookie exists $sweet
"),
$query->p("The current time is $current_time
");
end_html;
#cookie doesn't exist, set one and send it to the browser
}else{
$cookie = $query->cookie(-name=>'answers',
-value=>'Register',
-expires=>'+1h',
-path=>'/cgi-bin/');
print $query->header(-type=>'text/html', -cookie=>$cookie);
print "Cookie Set ";
}
exit;