#!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; #Generating a new session my $session = new CGI::Session("driver:File", undef, { #giving the directory where the session variables will be stored Directory=>"\\B2R6A056A\wwwroot\Amexpmo\login\amex\raman" } ) #incase of any error the session close giving an error or die $CGI::Session::errstr; print $cgi->header; print $cgi->start_html; #print <jkasgdf use constant SESSION_COOKIE => "MY_SITE_SIDE"; my $sid = $cgi->cookie("SESSION_COOKIE") || $cgi->param("sid") || undef; #creating a new session print "Your session id is ", $session->id(); # A cookie is being created which is then being send to the user browser my $cookie = $cgi->param(-name => SESSION_COOKIE, -value => $session->id, #sessiion expires after 3 hours -expires=>"+3h"); print $cgi->header(-cookie=>$cookie); $session->save_param($cgi, ["userid", "password"]); # this line saves all the available/accessible CGI params $session->save_param($cgi); #using data:;dumper to print the session variables getting stored print Dumper(\$session);