S
soup_or_power
Can someone please explain this sub taken out of embperl code. I am not
sure what the Storable::thaw is doing.Many thanks!
sub get_session {
my ( $r ) = @_;
if ( ref $r eq 'Apache' ) {
# ------------------------------------------------
# session from Apache request
# ------------------------------------------------
my $cookie_head = $r->header_in('Cookie');
my $cookie_name = $ENV{EMBPERL_COOKIE_NAME} || 'EMBPERL_UID';
my ( $session_id ) = ($cookie_head =~
/$cookie_name=(.*?)(?:\;|\s|$)/);
my %args = &get_session_env();
my $dbh = DBI->connect(
$args{DataSource},
$args{UserName},
$args{Password},
{ RaiseError => 0, AutoCommit => 1 }
) || return undef;
my $session = $dbh->selectall_arrayref( q{
SELECT a_session
FROM sessions
WHERE id = ?
}, { }, $session_id );
$dbh->disconnect();
return ( defined $session && $session ) ? Storable::thaw(
$session->[0][0] ) : undef;
} else {
# ------------------------------------------------
# session from udat
# ------------------------------------------------
&session_synch( $r );
return %$r;
}
}
sure what the Storable::thaw is doing.Many thanks!
sub get_session {
my ( $r ) = @_;
if ( ref $r eq 'Apache' ) {
# ------------------------------------------------
# session from Apache request
# ------------------------------------------------
my $cookie_head = $r->header_in('Cookie');
my $cookie_name = $ENV{EMBPERL_COOKIE_NAME} || 'EMBPERL_UID';
my ( $session_id ) = ($cookie_head =~
/$cookie_name=(.*?)(?:\;|\s|$)/);
my %args = &get_session_env();
my $dbh = DBI->connect(
$args{DataSource},
$args{UserName},
$args{Password},
{ RaiseError => 0, AutoCommit => 1 }
) || return undef;
my $session = $dbh->selectall_arrayref( q{
SELECT a_session
FROM sessions
WHERE id = ?
}, { }, $session_id );
$dbh->disconnect();
return ( defined $session && $session ) ? Storable::thaw(
$session->[0][0] ) : undef;
} else {
# ------------------------------------------------
# session from udat
# ------------------------------------------------
&session_synch( $r );
return %$r;
}
}