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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |