in reply to Re: Re: Please help me... Apache::Session::MySQL
in thread Please help me... Apache::Session::MySQL

Yes, it is a little complex. The FRHWebDB::Session is my module, I learned it from the book "Perl and MySQL for the web" by Paul DuBois.

I actually have the session untie, ONLY when the user clicks logout, which is pg=quit.

The code is this:
if ($in{pg} eq "quit" && defined($sess_ref)) {
    if ($sess_ref->attr ("remember_me") == 1) {
        $sess_ref->attr ("loggedin", 0);#just change it to 0
        $message = qq~You have been Logged Out$nname_ws!

~;#$nname_ws is their nickname with a # space in front of it, if no nick name then it's blank # (Out!) } else { Delete_Session_Forever($sess_ref); } } Here is the code in data.conf for the Delete_Session_Forever()... sub Delete_Session_Forever { $sess_ref = shift; $sess_ref->delete(); # Destroy session for good # Create cookie that tells browser to destroy the one it's storing $cookie = cookie (-name => "session_id", -value => $sess_ref->session_id(), -path => url (-absolute => 1), -expires => "-1d"); # Expire Yesterday $loggedin = 0; $sess_ref->attr ("loggedin", 0); $message = qq~You have been Logged Out<br>AND<br>Your Session Has been Deleted!<br><br>~; }

That is pretty much when it tells it to quit.

If you need to see the FRHWebDB::Session code let me know, I'll post it.

Thank you!
Richard
  • Comment on Re: Please help me... Apache::Session::MySQL

Replies are listed 'Best First'.
Re: Re: Please help me... Apache::Session::MySQL
by iguanodon (Priest) on Dec 29, 2002 at 00:17 UTC
    IMHO, you should explicitly call undef or untie on your session hash after every invocation of your script, to make sure Apache::Session will write the session info to the database. I think depending on this happening automagically is hit or miss at best.

    Note that calling undef or untie will not remove the session record from the table, there is a delete method for that. Calling the delete method may be what you want in your logout handler.