Connecting Tech Pros Worldwide Forums | Help | Site Map

Having trouble with CGI::Sessions

David Staschover
Guest
 
Posts: n/a
#1: Aug 3 '05
I'm trying to set up sessions in perl.

The session is initialized fine in session1.cgi

In session2.cgi, the correct session id is returned from the cookie, but
when I initialize the session, a new session is created. The original and
new session id don't match.

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<br>";
print '<a href="session2.cgi">Link to session2.cgi</a>';
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<br>";
$sid = $session->id();
print "New Session ID $sid<br>";
exit;




Closed Thread