#!/opt/bin/perl
#use strict;
use CGI::Carp;
use CGI;
use File::Spec;
use CGI::Session;
use Date::Manip;
#use CGI::Session::DB_File;
print "Content-type: text/html\n\n";
my $cgi = new CGI();
my $session = new CGI::Session(undef, $cgi,
{Directory=>File::Spec->tmpdir });
my $sweet = $cgi->cookie($session->name);
if ($sweet) {
print "cookie exists $sweet
";
my $ipa = $session->param("_SESSION_REMOTE_ADDR");
my $i = $session->param("NVISITS") || 0; #If Statement I can use for
other values
$session->param("NVISITS", ++$i);
my $current=&ParseDate("today");
my $d = $session->param("Dateid") || $current; #If Statement I can
use for other values
$session->param("Dateid", "$current");
$session->expire('+1m');
print $cgi->start_html(-title=>"Session"),
$cgi->h1("Session Information"),
#$cgi->h1("Hello World from CGI::Session/$CGI::Session::VERSION"),
$cgi->p("This is CGI::Session $CGI::Session::VERSION"),
$cgi->p("Your session id is " . $session->id . "");
print $cgi->div("You visited this page $i times so far, right? Date
$d IP Address: $ipa $sweet
");
#print $cgi->div("You visited this page $i times so far, right? Date
$d IP Address: $ipa cookie session: $sweet
");
#print $cgi->p("Cookie Session: $getcookie");
#print $cgi->end_html();
}else{
print "New cookie set
";
#Building a cookie to be sent to user
my $cookie = $cgi->cookie(-name=>$session->name,
-value=>$session->id, -expires=>'+1m');
# Setting cookie in the Browser:
print $cgi->header(-cookie=>$cookie);
#print $cgi->header(-type=>'text/html', -cookie=>$cookie);
#print $cgi->header(-cookie=>$cookie);
my $ipa = $session->param("_SESSION_REMOTE_ADDR");
my $i = $session->param("NVISITS") || 0; #If Statement I can use for
other values
$session->param("NVISITS", ++$i);
my $current=&ParseDate("today");
my $d = $session->param("Dateid") || $current; #If Statement I can
use for other values
$session->param("Dateid", "$current");
$session->expire('+1m');
}
exit;