#!/usr/bin/perl $dbn = "DBI:mysql:***"; $dbu = "***"; $dbp = "***"; use CGI; use DBI; use CGI::Session; my $cgi = new CGI; $dbh = DBI->connect($dbn, $dbu, $dbp, {RaiseError=>1,AutoCommit=>1}) or die ($DBI::errstr); &initsession; &addanothervalue; print $cgi->header; print "$sessionid

$session

"; sub addanothervalue { # -> comment out this line (to get working) $session->param('test',1); } sub initsession { #$session = new CGI::Session("driver:file",undef,{Directory=>'temp'}); # -> add my to this line below (to get working) $session = new CGI::Session("driver:MySQL",undef,{Handle=>$dbh}); $sessionid = $session->id; $session->expire('+1h'); }