i have tried to create a module which when used stores session variables
please let me know if i am wrong some where in my coding
package raman; use strict; use CGI::Carp qw(fatalsToBrowser); #die "Bad error here"; use CGI; use CGI::Cookie; use CGI::Session; my $cgi = new CGI; use lib "/usr/random/directory"; our @ISA = qw(Exporter); my $session_dir = "C:\\raman"; 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, { + 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 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); 1;
In reply to session module by rjsaulakh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |