in reply to Value for session set in CGI::Session is undef

In your "main program", you call:

print Dumper($logged_in, $session->param('user'));

But, $session isn't defined. It is defined (with "my" and the the "new CGI::Session()" call in the subroutine) and not passed back.

Try doing the $session = new... call in the main program and passing both the $session and $user variables to the sub.

Replies are listed 'Best First'.
Re^2: Value for session set in CGI::Session is undef
by bradcathey (Prior) on Apr 07, 2009 at 21:32 UTC

    Every poster was correct pointing out that $session was not defined in my calling program. Duh!

    So, I tried this first:

    my $logged_in = write_session( $user ); my $session = CGI::Session->load(); print Dumper($logged_in, $session->param('user'));

    which I thought would be the proper way to do it, but ended up following your advice with:

    my $session = new CGI::Session(); my $logged_in = write_session( $session, $user ); print Dumper($logged_in, $session->param('user'));

    which did the trick. Thanks.

    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot