Apache-JAF
view release on metacpan or search on metacpan
lib/Apache/JAF/Session.pm view on Meta::CPAN
sub new {
my ($class, $expire, @dsn) = @_;
my $dbh = DBI->connect(@dsn);
my $self = { };
my %cookies = Apache::Cookie->fetch();
my $id = $cookies{SESSION_ID} && $cookies{SESSION_ID}->value();
my $t = time();
my $expired = $dbh->selectall_arrayref(q{select id from sessions where ? - unix_timestamp(modified) > ?}, $FIXUP, $t, $expire);
foreach (@$expired) {
tie %$_, $class, $_->{id}, { Handle => $dbh, LockHandle => $dbh };
tied(%$_)->on_end($_) if tied(%$_)->can('on_end');
tied(%$_)->delete();
}
$id = $dbh->selectrow_array(q{select id from sessions where id = ?}, undef, $id);
tie %$self, $class, $id, { Handle => $dbh, LockHandle => $dbh };
$self->{active} = $t;
tied(%$self)->on_start($self) if !$id && tied(%$self)->can('on_start');
( run in 2.144 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )