Category: CGI WEB
Author/Contact Info drfrog666@hotmail.com
Description: after being frustrated with trying to figure out the docs and not finding any code online that would help me understand expiry functions in CGI::Session, i finally tooled around and got some code to work, i present it here for anyone that may find difficulty with the explaination in CGI::Session's documentation

im sure this isnt the best code but i hope it serves as a guide for anyone trying to figure this out!
#!/usr/bin/perl
use strict;
use CGI::Session;
use CGI;
use DBI;

my $driver="Pg";
my $dbname="drfrog";
my $host="127.0.0.1";
my $user="user";
my $password="password";
my $dbh = DBI->connect(  "dbi:$driver(PrintError=>1,RaiseError=>1,Tain
+t=>1):dbname=$dbname;host=$host", $user, $password    );

my $q=CGI->new;
my $id=$q->param('id')||undef;
print $id."\n";

my $session = new CGI::Session("driver:PostgreSQL", $id, {Handle=>$dbh
+});
my $sid = $session->id();

if (!$session->param("my_name"))
  {
print "no param";
}
$session->param("my_name",$session->param("my_name")+1 );
my $name = $session->param("my_name");


$session->expire( '+2m');
$session->expire("my_name" => '+1m');

if ($session->param('_SESSION_ETIME')<=$session->param('_SESSION_ATIME
+')-$session->param('_SESSION_CTIME'))

  {

print "time has expired\n";
}

undef ($session);
if ($id != $sid &&  defined $id)
{
print "session has expired\n";
}

print $sid."\n";
print $name."\n";
 $dbh->disconnect();