Having trouble with CGI::Sessions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Staschover

    Having trouble with CGI::Sessions

    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(un def,undef,{Dire ctory=>'/tmp/sessions'});
    $cookie = $cgi->cookie(CGISESS ID => $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("CGISES SID");
    $session = new CGI::Session(un def,$sid,{Direc tory=>'/tmp/sessions'});
    print "Original Session ID is $sid<br>";
    $sid = $session->id();
    print "New Session ID $sid<br>";
    exit;



Working...