Hi, i am setting a session dat in 1 file and trying to retrieve in another file. Not able to get the stored data. Need help. i can see the session file being created in the folder mentioned.

session1.pl

#!"\TBD\xampp\perl\bin\perl.exe" use CGI::Carp qw(fatalsToBrowser); use strict; use warnings; use CGI; use CGI::Session; my $cgi = new CGI; # Object initialization: my $session = new CGI::Session("driver:File", undef, {Directory=>' +d:/TBD'}); # getting the effective session id: my $sessionid = $session->id(); #print "$sessionid \n"; my $cookie = $cgi->cookie(CGISESSID => $session->id); print $cgi->header( -cookie=>$cookie ); # storing data in the session $session->param('my_name', 'Sherzod'); #printf ("<a href=\"session2.pl?%s=%s\">click me</a>", 'CGISESSID', $s +ession->id); print<<OUTPUT; <html> <body> <br><br> <form action="session2.pl" METHOD="POST"> <input type="hidden" name="CGISESSID" value="$sessionid"> <input type="submit" > </form> </body> </html> OUTPUT exit (0);
session2.pl
#!"\TBD\xampp\perl\bin\perl.exe" use CGI::Carp qw(fatalsToBrowser); use strict; use warnings; use CGI; use CGI::Session; my $cgi = new CGI; # Object initialization: print "Content-type: text/plain; charset=iso-8859-1\n\n"; my $sid = $cgi->cookie('CGISESSID') || $cgi->param('CGISESSID') || + undef; my $session = new CGI::Session(undef, $sid, {Directory=>'d:/TBD'}) +; my $name = $session->param("my_name"); exit (0);

In reply to cgi::session issue with session data retrival by saifuddin786

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.