I have a script successfully running for CGI::Session . i am able to get the store my session variables every time my script runs.
what i want to implement is when user goes on the next page i should be able to get his userid. i want his userid as i have to perform some actions in the database in relation to his userid .
can you please help me how do i move with it . what concept should i apply . i have read through the cgi::session doc in detail
my code for session variables is as below
#!c:\Perl\bin\perl.exe -w
use strict;
use CGI::Carp qw(fatalsToBrowser);
#die "Bad error here";
use CGI;
use CGI::Cookie;
use Data::Dumper;
use CGI::Session;
my $cgi = new CGI;
my $session_dir = "C:\\raman";
#Generating a new session
use constant SESSION_COOKIE => "MY_SITE_SIDE";
my $sid = $cgi->cookie("SESSION_COOKIE") || $cgi->param("sid") || unde
+f;
my $session = new CGI::Session("driver:File", $cgi,
{
+
#giving the directory where the session var
+iables will be stored
Directory=>$session_dir
}
)
#incase of any error the session close giving an error
or die $CGI::Session::errstr;
my $cookie = $cgi->param(-name => SESSION_COOKIE,
-value => $session->id,
#sessiion expires after 3 hours
-expires=>"+3h");
$cgi->header(-cookie=>$cookie);
#print $cgi->header;
#print $cgi->start_html;
#print <<HERE;
#<b>jkasgdf</b>
#print "Your session id is ", $session->id();
# A cookie is being created which is then being send to the user brows
+er
$session->param('username', 'raman');
#$session->save_param($cgi, ["username", "password"]);
#print $session->param('username'); #prints raman
# this line saves all the available/accessible CGI params
my $x= $session->save_param($cgi);
#print $x;
print "\n";
#returns the time
printf("Session was created on %s\n", scalar localtime($session->ctime
+));
#printf ("Session login time ", localtime( $session{_session_ctime}));
#using data:;dumper to print the session variables getting stored
#print Dumper(\@variable);