QuoteWenn in einer Session die nach 1 Stunde abläuft...
1 2 3 4 5 6 7 8 9 10 11 12
# If we get this far, we expect expire($param,$time) # ( This would be a great use of a Perl6 multi sub! ) else { my ($param, $time) = @_; if ( ($time =~ m/^\d$/) && ($time == 0) ) { delete $self->{_DATA}->{_SESSION_EXPIRE_LIST}->{ $param }; $self->_set_status( STATUS_MODIFIED ); } else { $self->{_DATA}->{_SESSION_EXPIRE_LIST}->{ $param } = $self->_str2seconds( $time ); $self->_set_status( STATUS_MODIFIED ); } }
1 2 3 4 5
sub CGI::Session::get_token_expiry() { my ( $self, $param ) = @_; # maybe more checks to protect against auto-vivification return $self->{_DATA}->{_SESSION_EXPIRE_LIST}->{$param}; }
2024-05-03T08:27:19 GwenDragonDanke für den Tip.
Es ist sinnvoll CGI::Session um ein paar Methoden aufzubohren.
1
2
3
4
5
6
7
8
9
10
# checking expiration tickers of individuals parameters, if any:
my @expired_params = ();
if ( $self->{_DATA}->{_SESSION_EXPIRE_LIST} ) {
while (my ($param, $max_exp_interval) = each %{ $self->{_DATA}->{_SESSION_EXPIRE_LIST} } ) {
if ( ($self->{_DATA}->{_SESSION_ATIME} + $max_exp_interval) <= time() ) {
push @expired_params, $param;
}
}
}
$self->clear(\@expired_params) if @expired_params;
1
2
3
4
5
6
if ( not defined $session->param( $tokenname ) { # Parameter der Session abgelaufen?
my $tok = CreateNewToken(); # Neues Token erstellen
$session->param( $tokenname, $tok ); # Token in Session speichern
$session->expire( "10m" ); # Token nach 10 Minuten ablaufen lassen
$session->flush(); # Session speichern
}
Quotereturns a session parameter set to $name or undef if it doesn't exist
— https://metacpan.org/release/MARKSTOS/CGI-Session-...
1
2
3
4
5
6
CREATE TABLE `session` (
`sid` varchar(48) NOT NULL DEFAULT '',
`data` text DEFAULT NULL,
`ctime` timestamp NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`sid`)
)
1
2
3
4
5
6
7
$VAR1 = [
{
'ctime' => '2024-05-04 15:52:50',
'data' => '$D = {\'_SESSION_ATIME\' => 1714831140,\'_SESSION_CTIME\' => 1714830769,\'_SESSION_ID\' => \'f79ea45bcfc2a2ed891f1bca982ac6d9\',\'_SESSION_REMOTE_ADDR\' => \'\'};;$D',
'sid' => 'f79ea45bcfc2a2ed891f1bca982ac6d9'
}
];