No, I regret to inform you there is no better way. You can and should include add a data stamp in every session entry, you can then go back through them letter with another script.
The whole Apache::Session::* is very undocumented, though I have read the src myself a few times. By default Apache::Session::DBI will store using a frozen copy of a Base64 bit encoded hash: This, thankfully, is easily reversible.
Here is some code that should show you the values you have stored, you can use this and a few simple sql tables, to move the data out of the frozen/base64 encoded hash into a real sql table.
use Storable q/thaw/;
use MIME::Base64;
use Data::Dumper;
use DBD::Pg;
use Carp;
use Apache::Session::Serialize::Base64 qw/unserializie/;
my $dbh = DBI->connect("dbi:Pg:dbname='TABLE_NAME'",q/postgres/,"",{Au
+toCommit =>0}) || croak "Could not Connect to DB $DBI::errstr";
my $sth = $dbh->prepare(qq{ SELECT "a_session" FROM sessions });
$sth->execute();
+
while ( my $col = ($sth->fetchrow_array)[0] ) {
my %hash = %{ thaw(MIME::Base64::decode( $col ) ) };
while ( my ($k, $v) = each %hash ) {
print "$col :\t $k => $v\n";
}
}
Evan Carroll www.EvanCarroll.com
| [reply] [d/l] |
I haven't studied the source of Apache::Session, but if your store is MySQL I think you can add a timestamp in the record which gets automatically updated with the current time everytime you update the record (just reading the record would not update it). Deleting "old" sessions then is easy and you don't have to unserialize the session-data to do so.
CountZero "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
| [reply] [d/l] |