in reply to Loading a session from CGI::Session

All, I would like to thank you for your help in this problem. I have now figured out the solution. It is in multiple parts.

1) I am running this using Active Perl on a Windows 2008 R2 Server. When specifying the new() or load() methods with undefined attributes, they default to the system temp folder for session file creation and read. What I have discovered is that the default permissions on the "c:\windows\temp" folder are set such that a user level account can traverse folder/execute file, Create files/write data, Create folders/append data; but cannot List folder/read data. So as I was experiencing, the file was being created, but then the load method, even if it had the correct session, did not have permission to actually read the file.

2) The load method was not pulling then CGISESSID from the cookie. I still have not figured out why, but I was able to work around it by pulling the CGISESSID from the cookie myself first, then assigning it in the attributes of the method.

The updated and now working code is below.

script1.pl use CGI; use CGI::Carp qw/fatalsToBrowser warningsToBrowser/; use CGI::Session ( '-ip_match' ); #my $q = new CGI; my $session = CGI::Session->new(undef, undef, {Directory=>'e:\tmp'} +); $session->param("TestName", "TestValue"); $session->flush(); print $session->header(-location=>'script2.pl'); script2.pl use CGI; use CGI::Carp qw/fatalsToBrowser warningsToBrowser/; use CGI::Session ( '-ip_match' ); use CGI::Cookie; # fetch existing cookies %cookies = CGI::Cookie->fetch; $sessionid = $cookies{'CGISESSID'}->value; my $session = CGI::Session->load(undef, $sessionid, {Directory=>'e:\ +tmp'}) or die CGI::Session->errstr(); print $session->id . " - " . $session->param('TestName'), "<br>"; print $session->dump() . " <-- Result of dump", "<br>";

Replies are listed 'Best First'.
Re^2: Loading a session from CGI::Session
by pazt (Acolyte) on Aug 07, 2016 at 06:12 UTC
    Helped me a lot. Thanks
Re^2: Loading a session from CGI::Session
by Anonymous Monk on Jan 11, 2018 at 17:24 UTC
    i don't know why but it gives below error: Can't call method "value" on an undefined value at image.cgi line 16.