#!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") || undef; my $session = new CGI::Session("driver:File", $cgi, { #giving the directory where the session variables 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 "Your session id is ", $session->id(); # A cookie is being created which is then being send to the user browser $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);