d_i_r_t_y has asked for the wisdom of the Perl Monks concerning the following question:

i'm having some trouble getting Apache::Session::MySQL to work 'out-of-the-box' as per the given docs; ie: Apache::Session states that it was designed to work under a mod-perl environment, but not necessarily so. in my case, i have successfully set up the appropriate mysql database + 'sessions' table, and using the code below, can tie the hash and can view the DB connection using the mysql text client. however, writing and reading from the tied hash is unsuccessful and no data is ever written to the mysql 'sessions' table as expected.

here is the code:

sub Restore_Session { my $class = shift; my $cgi = shift || die "No CGI handle..."; my $cookie = $cgi->cookie( $SESSION_COOKIE_NAME ); warn ( $cookie ) ? "### got session cookie '$cookie'" : "### no session cookie" ; tie %Session, 'Apache::Session::MySQL', $cookie, { 'DataSource' => "dbi:mysql:$DB_NAME;host=$HOSTNAME;por +t=$HOSTPORT", 'UserName' => $DB_USERNAME, 'Password' => $PASSWORD, 'LockDataSource' => "dbi:mysql:$DB_NAME;host=$HOSTNAME;por +t=$HOSTPORT", 'LockUserName' => $DB_USERNAME, 'LockPassword' => $PASSWORD, } ; warn "### session id is '$Session{_session_id}'"; $Session{'some crap'} = 'some value crap'; warn "### current session parameters:" . (( %Session > 0 ) ? (join "\t", '', map {"'$_' => '$Session{$_}'"} keys %Sessi +on) : " none... starting new session\n") ; return (%Session > 0); } sub Save_Session { my $class = shift; my $cgi = shift || $CGI || die "No CGI handle..."; $Session{'time_now'} = localtime(); warn "### current session parameters:" . (( %Session > 0 ) ? (join "\t", '', map {"'$_' => '$Session{$_}'"} keys %Sessi +on) : "none... saving empty session!!!\n") ; my $session_id = $Session{_session_id}; warn "### session id is '$session_id'"; return $cgi->cookie( -name => $SESSION_COOKIE, -value => $session_id, -expires => '+1h', -path => '/', ); }
the method 'Restore_Session' is called near the start of the script, and 'Save_Session' is called just prior to sending the http headers. i think i can say that there is no other funny business outside these methods which could mess around with the tied hash.

the 'warn's in this code indicate that the hash does not have any data - despite the fact that the DB table does have session id's added to it (but no data...), and that the cookie stuff all works as it should. so, it is like the tied hash is refusing to STORE or FETCH my data for some reason, or i am just missing something.

any ideas? thanks in advance...