Problem with CGI::Sessions in Linux

Discussion in 'Perl Misc' started by David Staschover, Aug 4, 2005.

  1. 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;
     
    David Staschover, Aug 4, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Cox [Microsoft MVP]

    Re: Relationship between IIS Sessions and ASP.NET Sessions?

    Ken Cox [Microsoft MVP], Aug 8, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    5,420
    Luther Miller
    Aug 8, 2003
  2. Andrew Chalk

    Tracking Sessions in a Python CGI app.

    Andrew Chalk, Sep 4, 2003, in forum: Python
    Replies:
    2
    Views:
    423
    Andrew Chalk
    Sep 5, 2003
  3. Christoph Haas

    Re: Best way to handle cgi sessions

    Christoph Haas, Oct 14, 2005, in forum: Python
    Replies:
    0
    Views:
    564
    Christoph Haas
    Oct 14, 2005
  4. scottymo
    Replies:
    3
    Views:
    769
    Dominick Baier
    Sep 30, 2006
  5. Bookham Measures

    Moving from ASP Sessions to Database Sessions

    Bookham Measures, Jul 23, 2007, in forum: ASP General
    Replies:
    19
    Views:
    601
    Bookham Measures
    Aug 23, 2007
Loading...

Share This Page