I even looked into Session.pm and MySQL.pm.
The following code is in sub load() and flush() from Session.pm:
Code: Select all
sub load
..........
# checking for expiration ticker
if ( $self->{_DATA}->{_SESSION_ETIME} ) {
if ( ($self->{_DATA}->{_SESSION_ATIME} + $self->{_DATA}->{_SESSION_ETIME}) <= time() ) {
$self->_set_status( STATUS_EXPIRED ); # <-- so client can detect expired sessions
$self->_set_status( STATUS_DELETED ); # <-- session should be removed from database
$self->flush(); # <-- flush() will do the actual removal!
return $self;
}
}
Code: Select all
sub flush
..........
if ( $self->_test_status(STATUS_DELETED) ) {
defined($driver->remove($self->id)) or return $self->set_error( "flush(): couldn't remove session data: " . $driver->errstr );
$self->{_DATA} = {}; # <-- removing all the data, making sure
# it won't be accessible after flush()
return $self->_unset_status(STATUS_DELETED);
}
Code: Select all
MySQL.pm
-------------
# removes the given data and all the disk space associated with it
sub remove {
my ($self, $sid, $options) = @_;
my $dbh = $self->MySQL_dbh($options);
my $lck_status = $dbh->selectrow_array(qq|SELECT GET_LOCK("$sid", 10)|);
unless ( $lck_status == 1 ) {
$self->error("Couldn't acquire lock on id '$sid'. Lock status; $lck_status");
return undef;
}
$dbh->do(qq|DELETE FROM $TABLE_NAME WHERE id=?|, undef, $sid); =====> #83
$lck_status = $dbh->selectrow_array(qq|SELECT RELEASE_LOCK("$sid")|);
unless ( $lck_status == 1 ) {
$self->error("Couldn't release lock of '$sid'. Lock status: $lck_status");
return undef;
}
return 1;
}
Logout section works!
-----------------------
Code: Select all
if ($cgi->param('action') eq 'logout') {
$session = CGI::Session->load("driver:MySQL", $cgi, {Handle=>$dbh}) or die CGI::Session->errstr;
$session->delete();
# flush is needed, otherwise, it does not remove the session from DSN (MySQL)
$session->flush();
print $session->header(-location=>'thankyou.html');
}
Code: Select all
$session = CGI::Session->load("driver:MySQL", $cgi, {Handle=>$dbh}) or die CGI::Session->errstr();
I then posted a question in CPAN forum to see if I can get a response.