%shared>
## Verfiy we have a cookie with a _session_id
my $c = Apache2::Cookie->fetch($r);
if ( exists $c->{'WBT_Session'} ) {
$c= ($c->{'WBT_Session'}->value)[0];
} else {
$m->clear_buffer;
$m->subexec('/index.html', error => 201 );
$m->abort;
}
## Verify we have session that matches cookies ID
my %APACHE_SESSION;
eval {
tie %APACHE_SESSION, 'Apache::Session::Postgres', $c, {
Handle => $dbh,
Commit => 1,
};};
if ( $@ ) {
if ( $@ ) {
## No tuple with matching ID (form cookie), bogus data.
$m->clear_buffer;
$dbh->rollback;
$m->subexec('/index.html', error => 301 );
$m->abort;
} }
## Verify that the sessioned user still has an entry in the users table
## Save user information into $U by ref
my $U = $dbh->selectrow_hashref(
qq{ SELECT * FROM "users" WHERE pkid = ? }, {}, $APACHE_SESSION{'pkid'}
);
if ( defined $U ) {
##@@## HERE IS PROBLEM
##@@## WORKS FINE IF I DON'T SEND S ( %APACHE_SESSION REF )
##@@## STALLS IF I SEND S!
$m->call_next( S => \%APACHE_SESSION, U => $U);
} else {
$m->clear_buffer;
$m->subexec('/index.html', error => 101 );
$m->abort;
}
%shared>
<%cleanup>
$dbh->commit();
untie %APACHE_SESSION;
%cleanup>
####
if ( defined $U )
{
$m->call_next( S => \%APACHE_SESSION, U => $U);
}
####
if ( defined $U )
{
my %APACHE_SESSION = %APACHE_SESSION;
$m->call_next( S => \%APACHE_SESSION, U => $U);
}