[Israel.pm] Apache::Session::MySQL question?

ik idokan at gmail.com
Thu Oct 26 03:23:53 PDT 2006


See answer inline.

>hello perl programmers, I need realy a help in this
>why when i am trying to print the session data in the
>next perl code nothing is printed.
>i know that the session saves the data between the
>http requests. i noticed that the session id is saved
>fine but the other data nothing is saved.
>my %session = undef;

Use "our" instead of "my" also for the $dbh. Specially when you are in
strict mode.

>my $cookie;
>sub f1
>print "session id: " . $session{_session_id};    #
>works fine ..
>$session{pla} = 'plaplapla';
>print "<br>pla is: " . $session{pla};     # prints
>plaplapla.. (ok)
># this function is called in the next http request
>sub f2
>print "session id: " . $session{_session_id};   #
>works fine ..
>print "<br>pla is: " . $session{pla};     # nothing
>printed..  why not printing (plaplapla)??????
>sub open_session
>$cookie = cookie('session_id');

Does cookie have the correct id ? It should return a value such a
"1555ABD33F" ... does it the same value of the session that you have
created ?

>tie %session, 'Apache::Session::MySQL',$cookie,
>{Handle => $dbh,  LockHandle => $dbh};

Another thing you should consider looking for, is to close the session
when you exit your execution, and force writing the content using
flush .
Close the database after you closed the session.

Do you have any warnings or error messages when you use: "use warnings" ?
When using warnings, you can have find a lot of (bad written) details
regarding the Apache::Session module.


More information about the Perl mailing list