Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

cgi session

by rjsaulakh (Beadle)
on May 28, 2005 at 07:09 UTC ( [id://461295]=perlquestion: print w/replies, xml ) Need Help??

rjsaulakh has asked for the wisdom of the Perl Monks concerning the following question:

my following program is working fine but i am not able to find where my session variable are getting stored or at all there getting stored or not , though i have given a path where need to be stored

another query is that i am using this script to log session variables for user who login through a html site .so where do i call this script so that i keep a log of all user valid or invalid trying to login in

after logging in user will be accessing database and also editing it . how can i keep track of this
do i write another script for take help of sessio variables for the same

#!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 = new CGI::Session("driver:File", undef, { + Directory=>"\\B2R6A056A\wwwroot\Amexpmo\login\amex\raman" } ) or die $CGI::Session::errstr; print $cgi->header; print $cgi->start_html; #print <<HERE; #<b>jkasgdf</b> use constant SESSION_COOKIE => "MY_SITE_SIDE"; my $sid = $cgi->cookie("SESSION_COOKIE") || $cgi->param("sid") || unde +f; #creating a new session print "Your session id is ", $session->id(); # A cookie is being created which is then being send to the user brows +er my $cookie = $cgi->cookie(CGISESSID => $session->id ); print $cgi->header(-cookie=>$cookie); $session->save_param($cgi, ["userid", "password"]); # this line saves all the available/accessible CGI params $session->save_param($cgi); print Dumper(\$session); $session->expire('+3h'); #HERE #print $cgi->end_html;

Replies are listed 'Best First'.
Re: cgi session
by bart (Canon) on May 28, 2005 at 10:43 UTC
    Directory=>"\\B2R6A056A\wwwroot\Amexpmo\login\amex\raman"
    I guess this is a Windows machine, and a network drive? (The latter seems like an extremely silly idea to me. IMO sessions should be stored on a local drive.)

    Please double your backslashes. That is necessary so perl will use them as a single backslash.

    Directory=>"\\\\B2R6A056A\\wwwroot\\Amexpmo\\login\\amex\\raman"

    or, following erix' advise in the Chatterbox, replace them with forward slashes:

    Directory=>"//B2R6A056A/wwwroot/Amexpmo/login/amex/raman"

    Do take care to make sure the directory you indicated actually exists, I don't know what exactly will happen if it doesn't exist, but I'm pretty sure perl will not create the directory for you.

Re: cgi session
by castaway (Parson) on May 28, 2005 at 08:13 UTC
    Did you mean to print the cookie header *inside* the HTML tags? (ie after you called start_html), the browser wont get the cookie that way, iirc.

    Can you describe what you want the code to do, line by line? It looks a little mixed up.

    C.

    A reply falls below the community's threshold of quality. You may see it by logging in.
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: cgi session
by Zaxo (Archbishop) on May 28, 2005 at 07:26 UTC

    This appears to be pasted together from a number of unrelated examples. What is $sid for? Where does $session come from? [ Sorry, missed the assignment in line 011. Please adjust indentation and line spacing. ]

    What is this supposed to do if it is "working fine"? I don't see how calling a method of an undefined variable can be characterized that way.

    After Compline,
    Zaxo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://461295]
Approved by Zaxo
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-03-29 14:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found