Problems with CGI::Session in Perl
am 08.08.2005 17:25:28 von David StaschoverHi,
I'm trying to set up sessions in perl.
session1.cgi defines a new session and sets a cookie. In session2.cgi, the
correct session id is returned from the cookie, but when I initialize the
session, a new session is created.
The example is below. Any help would be appreciated!
Thanks,
- David
session1.cgi:
#!/usr/bin/perl
use CGI::Session;
use CGI;
$cgi = new CGI;
$session = new CGI::Session(undef,undef,{Directory=>'/tmp/sessions'});
$cookie = $cgi->cookie(CGISESSID => $session->id);
print $cgi->header( -cookie=>$cookie );
$sid=$session->id;
print "Session ID is $sid
";
print '';
exit;
session2.cgi
#!/usr/bin/perl
print "Content-type: text/html\n\n";
use CGI::Session;
use CGI;
$cgi = new CGI;
$sid=$cgi->cookie("CGISESSID");
$session = new CGI::Session(undef,$sid,{Directory=>'/tmp/sessions'});
print "Original Session ID is $sid
";
$sid = $session->id();
print "New Session ID $sid
";
exit;