i m trying to maintain session variables. in my script i am successfully able to generate a session file when ever a user enters his login details in the login page . i m also able to successfull generate the cookie containg the session id to be sent to the user browser .

my problem starts from that i am not able to fetch the cookie sent to the user and take the session id from it second problem is that when ever user goes to another page it doesnt reintialize the existing session but creates a new one which should not happen </p.

i want to go step by step so please guide me where i am doing mistake in fetching a cookie and getting sid from it

#!c:\Perl\bin\perl.exe -w use CGI::Carp qw(fatalsToBrowser); use CGI qw/:standard/; use CGI::Cookie; use Data::Dumper; use CGI::Session; my $cgi = new CGI; print $cgi->header; my $sid; ##session id my $session_dir = "C:\\raman"; ## place where CGI Session files are s +tored #here i am just trying to test whether i am able to fetch the cookie #getting success i can do some more things %cookies = fetch CGI::Cookie; $id = $cookies{'sessionID'}->value; print $id ; my $session = new CGI::Session("driver:File", $cgi, {Directory=>$sessi +on_dir}) or die $CGI::Session::errstr; $sid=$session->id(); $cookie = new CGI::Cookie(-name => 'sessionID', -value => $sid, -expires => '+3h' ); print $cgi->header( -cookie=>$cookie); $session->save_param($cgi, ["username", "password"]); $x= $session->save_param($cgi);

In reply to session script by rjsaulakh

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.