in reply to Eval and Exiting

Maybe it's not what you think of as your immediate problem, but that ge definitely looks wrong to me. That test will always return true, even if that value is not set. Most likely
if ($cookies{PHPSESSID}) {
would be enough of a test, as it is supposed to be an object, thus true, if set at all.

I no longer see a reason for the eval wrapper, either, as there isn't much reason I can see for it to fail. Here's my version:

unless ($cookies{PHPSESSID}) { $query->redirect(-location=>$redirecturl."0"); exit; } $session = PHP::Session->new($cookies{PHPSESSID}->value); $id = $session->id;
Untested, though.