in reply to Perl CGI::Sessions

please make sure that your sessions are send to browser by checking $f_name = $session->param('user_name'); In the code for second page, check for if ($session->is_expired) will fail as your session is valid. For some reason session is empty. CGI::Session->load() says that Notice, all expired sessions are empty, but not all empty sessions are expired! So make sure that your session data for user_name is set in browser properly.

Also, Why are you using CGI object to set cookie when you can do it with $session object itself like  print $session->header();

Replies are listed 'Best First'.
Re^2: Perl CGI::Sessions
by dariusj (Sexton) on Sep 07, 2007 at 13:24 UTC
    Thanks for your reply - it's taken me a while to get back to this code, but I need to get it finished soon!
    As you suggested, I got rid of $cookie altogether, now I'm just using
    $session->header();
    - however things don't seem to have changed.
    I realise the point you're making regard the CGI::Session->load(), in fact the sessions aren't passed at all, they aren't expired, but empty!
    I tried $session->param('user_name'), but get no result. I think my code's not finding the CGISESSID server-side file that is being created. I tried
    $session = CGI::Session->load(undef, undef, {Directory=>'./tmp'}) or die CGI::Session->errstr();
    (i.e. using the CGI::Session->new parameters with load, to try and point it to the correct directory), but this doesn't seem to find the files either.
    Can anyone see something wrong in my code? I hope it's clear what I've done... otherwise just ask - would seriously appreciate any help!
    Thanks!