# $sid = '7032f2c7f5a2c721a483dc75fc29595e';
$session = new CGI::Session("driver:MySQL", $sid, {Handle=>$dbh});
####
#!/usr/bin/perl
use strict; use warnings;
select STDOUT; $| = 1;
use CGI;
use CGI::Session;
my $existn=0;
my $sid=make_first();
sleep 10; find_if_exist ($sid);
sleep 20; find_if_exist ($sid);
find_if_exist('abcd');
exit;
sub make_first {
my $session = new CGI::Session(undef, undef, {Directory=>'.'});
my $sid=$session->id;
$session->expires('+15s');
$session->param('user_id',time);
$session->flush();
return $sid;
}
sub find_if_exist {
my $sid0=shift;
$existn++;
print '******Exist call:'.$existn."\n";
my $session = new CGI::Session(undef, $sid0, {Directory=>'.'});
my $sid=$session->id;
my $user=$session->param('user_id');
unless (defined $user) {$user='undef-as-string'; }
unless ($sid0 eq $sid) {print "********different "; }
print 'sid0:'.$sid0.' sid:'.$sid."\n";
print 'user:'.$user."\n\n";
}
####
******Exist call:1
sid0:2bd4a7c8d0001e49e97dc332d6bf619e sid:2bd4a7c8d0001e49e97dc332d6bf619e
user:1491953482
******Exist call:2
********different sid0:2bd4a7c8d0001e49e97dc332d6bf619e sid:bcd0c39467ce09c5b5be9910f9e1798b
user:undef-as-string
******Exist call:3
********different sid0:abcd sid:2dd5bc5bc5e297150b1e4c7f58166135
user:undef-as-string