1. It depends.
2. You can either edit CGI::Session::MySQL or edit your own (I called mine CGI::Session::MySQLtheSequel...no pun intended). You will need the following table created in your database:
CREATE TABLE sessions (
id CHAR(32) NOT NULL UNIQUE,
a_session TEXT NOT NULL,
expires int unsigned NOT NULL
);
You will also need to alter the store sub in your package.
sub store {
my ($self, $sid, $options, $data) = @_;
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|REPLACE INTO $TABLE_NAME (id, a_session, expires) VALU
+ES(?,?,?)|, undef, $sid, $self->freeze($data),$self->expire() + $self
+->atime());
return $dbh->selectrow_array(qq|SELECT RELEASE_LOCK("$sid")|);
}
Now in your code for clearing out the expired session id's, run this do:
$dbh->do("delete from sessions where expires<?",undef,time());
Just be certain to set $session->expire() to something or it will never get deleted. Hope this helps.
antirice The first rule of Perl club is - use Perl The ith rule of Perl club is - follow rule i - 1 for i > 1 |