bradcathey has asked for the wisdom of the Perl Monks concerning the following question:
Fellow Monasterians,
Note: I posted a similar question the other day, but have simplified it somewhat.
Anyway, I'm on a mission to understand CGI::Sessions but I'm missing something.
My guess is that I'm not not using new CGI::Session() properly. Here is a reduction of a much larger application. I hope someone can spot the issue here, without lots of extraneous code.
Problem: it looks like I'm setting a new session and losing my value: logged-in. Obviously, I'd like to keep the session the same, and the value.
my ($logged_in, $session_id) = write_session(); # Dumper to file shows # $VAR1 = 1; # $VAR2 = 'ae83ec8591d8579c1955d3e798dde74b'; my ($logged_in, $session_id) = check_session(); # Dumper to file shows # $VAR1 = undef; # $VAR2 = '1209a2de95b31a59d338f70458702860'; sub write_session { my $session = new CGI::Session(); print $session->header(); $session->param('logged_in' => 1); $session->expire('+2h'); return ( $session->param('logged_in'), $session->id() ); } sub check_session { my $session = new CGI::Session(); return ( $session->param('logged_in'), $session->id() ); }
Thanks in advance.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI::Session appears to be overwriting itself
by Anonymous Monk on Feb 17, 2009 at 01:48 UTC | |
|
Re: CGI::Session appears to be overwriting itself
by jethro (Monsignor) on Feb 17, 2009 at 01:44 UTC | |
by Anonymous Monk on Feb 17, 2009 at 02:42 UTC | |
by bradcathey (Prior) on Feb 17, 2009 at 02:24 UTC | |
|
Re: CGI::Session appears to be overwriting itself
by Anonymous Monk on Feb 17, 2009 at 02:59 UTC |