Hi,
I am trying to use Apache::Session with mod_perl because I heard that it is
a little faster than CGI::Session. The problem is that I cannot save
variables in the created sessions. They are created, but no data is saved.
Here is what I have tried and I am sure I am missing something:
#Create session:
my %session;
eval {
tie(%session, 'Apache::Session::MySQL', undef, {Handle => $dbh, LockHandle
=> $dbh});
};
#Put a variable in it:
$session{username} = 'etc';
#get the session id:
my $session_id = $session{_session_id};
undef %session;
#Get the saved session:
my %new_session;
eval {
tie(%new_session, 'Apache::Session::MySQL', $session_id, {Handle => $dbh,
LockHandle => $dbh});
};
#Get the var from the session:
print $new_session{username};
undef %new_session;
###
After running this script, nothing is printed and the hash element
"username" is not saved in the MySQL table, but just the session ID.
I have created the MySQL table using:
create table sessions(id varchar(32) not null primary key, a_session text);
Thank you.
Teddy