Problem with CGI::Sessions in Linux

  • Thread starter David Staschover
  • Start date
D

David Staschover

Hi,

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.

Any help would be appreciated!

- 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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top