Revision 8fdebd9c
Von Moritz Bunkus vor fast 14 Jahren hinzugefügt
SL/Auth.pm | ||
---|---|---|
6 | 6 |
use IO::File; |
7 | 7 |
use Time::HiRes qw(gettimeofday); |
8 | 8 |
use List::MoreUtils qw(uniq); |
9 |
use YAML; |
|
9 | 10 |
|
10 | 11 |
use SL::Auth::Constants qw(:all); |
11 | 12 |
use SL::Auth::DB; |
... | ... | |
495 | 496 |
$sth = prepare_execute_query($form, $dbh, $query, $session_id); |
496 | 497 |
|
497 | 498 |
while (my $ref = $sth->fetchrow_hashref()) { |
498 |
$self->{SESSION}->{$ref->{sess_key}} = $ref->{sess_value}; |
|
499 |
$form->{$ref->{sess_key}} = $ref->{sess_value} if (!defined $form->{$ref->{sess_key}}); |
|
499 |
my $value = $self->_load_value($ref->{sess_value}); |
|
500 |
$self->{SESSION}->{$ref->{sess_key}} = $value; |
|
501 |
$form->{$ref->{sess_key}} = $value if (!defined $form->{$ref->{sess_key}}); |
|
500 | 502 |
} |
501 | 503 |
|
502 | 504 |
$sth->finish(); |
... | ... | |
506 | 508 |
return SESSION_OK; |
507 | 509 |
} |
508 | 510 |
|
511 |
sub _load_value { |
|
512 |
return $_[1] if $_[1] !~ m/^---/; |
|
513 |
|
|
514 |
my $value; |
|
515 |
eval { |
|
516 |
$value = YAML::Load($_[1]); |
|
517 |
1; |
|
518 |
} or return $_[1]; |
|
519 |
|
|
520 |
return $value; |
|
521 |
} |
|
522 |
|
|
509 | 523 |
sub destroy_session { |
510 | 524 |
$main::lxdebug->enter_sub(); |
511 | 525 |
|
... | ... | |
606 | 620 |
sub set_session_value { |
607 | 621 |
$main::lxdebug->enter_sub(); |
608 | 622 |
|
609 |
my $self = shift; |
|
623 |
my $self = shift; |
|
624 |
my %params = @_; |
|
610 | 625 |
|
611 | 626 |
$self->{SESSION} ||= { }; |
612 | 627 |
|
613 |
while (2 <= scalar @_) { |
|
614 |
my $key = shift; |
|
615 |
my $value = shift; |
|
616 |
|
|
617 |
$self->{SESSION}->{$key} = $value; |
|
628 |
while (my ($key, $value) = each %params) { |
|
629 |
$self->{SESSION}->{ $key } = YAML::Dump($value); |
|
618 | 630 |
} |
619 | 631 |
|
620 | 632 |
$main::lxdebug->leave_sub(); |
Auch abrufbar als: Unified diff
Session-Inhalt als YAML-Dump speichern und laden