L
L. D. James
Can somebody tell me why accessing the sessions will cause the mysql
driver to fail.
Please look at the follow code. I have commented out the access
line. Please notice that refreshing the page will increment the
count, because it will communicate with the session. Uncommenting
then line, and the count variable will stop incrementing.
#--------------------------- Code Begin
-------------------------------
use warnings;
use strict;
use DBI;
use CGI qwstandard);
use Switch;
use CGI::Carp qw(fatalsToBrowser);
use CGI::Session::MySQL;
my $name;
my $count;
my $query = new CGI;
my $dbh = DBI->connect( "DBI:mysql:flightmembers:localhost",
"username", "userpass" );
my $sid = cookie('CGISESSID') || param('CGISESSID') || undef;
my $session = new CGI::Session("driver:MySQL", $sid, {Handle=>$dbh})
or die "Session Error...";
sub processdata()
{
my $username = 'No Data Yet';
print "<br>-->$name<--<br>-->$count<--<br>";
# $username = $session->param('f_name');
print "<br>Processing Data for $username.<br>";
}
print $session->header();
$name = $session->param('f_name');
$count = $session->param("count") || "0";;
$count++;
$session->param('f_name','Larry James');
$session->param('count',"$count");
&processdata();
#---------------------------- Code End
driver to fail.
Please look at the follow code. I have commented out the access
line. Please notice that refreshing the page will increment the
count, because it will communicate with the session. Uncommenting
then line, and the count variable will stop incrementing.
#--------------------------- Code Begin
-------------------------------
use warnings;
use strict;
use DBI;
use CGI qwstandard);
use Switch;
use CGI::Carp qw(fatalsToBrowser);
use CGI::Session::MySQL;
my $name;
my $count;
my $query = new CGI;
my $dbh = DBI->connect( "DBI:mysql:flightmembers:localhost",
"username", "userpass" );
my $sid = cookie('CGISESSID') || param('CGISESSID') || undef;
my $session = new CGI::Session("driver:MySQL", $sid, {Handle=>$dbh})
or die "Session Error...";
sub processdata()
{
my $username = 'No Data Yet';
print "<br>-->$name<--<br>-->$count<--<br>";
# $username = $session->param('f_name');
print "<br>Processing Data for $username.<br>";
}
print $session->header();
$name = $session->param('f_name');
$count = $session->param("count") || "0";;
$count++;
$session->param('f_name','Larry James');
$session->param('count',"$count");
&processdata();
#---------------------------- Code End