http://www.perlmonks.org?node_id=1050271

msinfo has asked for the wisdom of the Perl Monks concerning the following question:

hi, i am trying to use cgi::session, but no luck yet. index.html has form which gets user credentials, matches them with mysql databases values, and if right, then sets a session otherwise shows login.html
# create a new session my $session = CGI::Session->new() or die CGI::Session->errstr; print $session->header(); #setting session to expire in 1 hour $session->expire("+1h"); #further in page # logout option print "<a href='logout.cgi'>logout </a></br>"; # check option print "<a href='check.cgi'>check page</a>"
this page gives output properly, it gnerates session id, but when i click on check page link, it doesn't show me session info and i always get "no session" message.
# cgi page my $cgi = CGI->new; #print $cgi->header(); print $cgi->start_html(); print $cgi->p("hello"); print $cgi->cookie('CGISESSID'); # load session info my $session = CGI::Session->load() or die CGI::Session->errstr; print $session->header(); if ($session->is_empty) { print $cgi->p("no session"); } else { print $cgi->p("<b>session data loaded</b>"); print $session->name; print $session->id; print $session->is_expired; } print $cgi->end_html();
and this is code in logout.cgi
# Delete the session for good: my $session = CGI::Session->load() or die CGI::Session->errstr; $session->delete(); $session->flush(); print $session->header(-location=>'http://localhost');
what am i doing wrong?