# $id is either a cookie-passed session ID or undef # $sargs is a hashref of options eval { tie %session, 'Apache::Session::Postgres', $id, $sargs }; if ($@ =~ /^Object does not exist/) { # try to get a new session eval { tie %session, 'Apache::Session::Postgres', undef, $sargs }; die "Can't get new session: $@" if $@; } elsif ($@) { die "Can't get session. ID (if any): '$id' : $@"; }