in reply to Problems with CGI Sessions

You should call $session->flush() after you stored some values (including expiry times).

BTW there's no need to create a new session in the elsif branch.