Hi there,

I've already asked once how to use session to store a simple value and applied the answer to my code, also gone through the CGI:: Session tutorial a few times and still cannot get my code to work.

I've not touched Perl in a few years so sorry if i'm making a simple mistake.

I have two files, sesssion1.pl and session2.pl - when you click on the link printed out by session1.pl it should take you to session2.pl and print out the value stored in the session. Why is this not working?

SESSION1.PL
use CGI::Session; use CGI; my $cgi = new CGI; my $session = new CGI::Session("driver:File", $cgi, {Directory=>'/tmp' +}); $cookie = $cgi->cookie(CGISESSID => $session->id ); print $cgi->header(-cookie=>$cookie); $session->param('f_name', 'Sherzod'); print '<a href="session2.pl">Page 2</a>';


SESSION2.PL
use strict; use CGI::Session; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use CGI; my $cgi = new CGI; my $sid = $cgi->cookie("CGISESSID") || undef; my $session = new CGI::Session("driver:File", $sid, {Directory=>'/tmp' +}); my $cookie = $cgi->cookie(CGISESSID => $session->id ); print $cgi->header(-cookie=>$cookie); my $name = $session->param("l_name"); print $name;


Any help greatly appreciated. Kind Regards Steve

In reply to Sessions In With CGI::Session by SketchySteve

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.