I tried your code, and it appeared to work, returning

IP_MATCH is turned on Session loaded 209957231a595d0c638d37cda1f4d2a8

but I noticed that the session ID that is printed is not pulled from the loaded session object "$cse", it's pulled from the "$sessionid" variable which was set by the original session. With that in mind, I modified the coded a little. adding

print $cse->id;

to the end.

use strict; use warnings; use CGI; use CGI::Session; my $session = CGI::Session->new(); $session->expire('5m'); $session->param( 'TestName', 'TestValue' ); my $sessionid = $session->id; $ENV{REMOTE_ADDR} = '127.0.0.1'; $session->flush; $session = CGI::Session->new($sessionid); CGI::Session->import qw/-ip_match/; $CGI::Session::IP_MATCH = 1; print "IP_MATCH is turned on\n"; if (my $cse = CGI::Session->load($sessionid)) { print "Session loaded\n"; } else { die CGI::Session->errstr(); } print $sessionid, "\n"; print $cse->id;

The result:

500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

So it's like the session is still not loading. If I change the code a little more.

use strict; use warnings; use CGI; use CGI::Session; my $session = CGI::Session->new(); $session->expire('5m'); $session->param( 'TestName', 'TestValue' ); my $sessionid = $session->id; $ENV{REMOTE_ADDR} = '127.0.0.1'; $session->flush; $session = CGI::Session->new($sessionid); CGI::Session->import qw/-ip_match/; $CGI::Session::IP_MATCH = 1; print "IP_MATCH is turned on\n"; my $cse = CGI::Session->load($sessionid); if ($cse) { print "Session loaded\n"; } else { die CGI::Session->errstr(); } print $sessionid, " - \n"; print $cse->id, " - \n";

I get a returned Session object, but no session data. Notice I pulled defining the "$cse" variable out of the if statement.

result of the above code is:

IP_MATCH is turned on Session loaded 35d4f016b7aca2f7b3ae032291d2ec74 - -


In reply to Re^2: Loading a session from CGI::Session by SitrucHtims
in thread Loading a session from CGI::Session by SitrucHtims

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.