d_i_r_t_y has asked for the wisdom of the Perl Monks concerning the following question:
here is the code:
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.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 '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...
|
|---|