Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

ie with cgi::session not showing same session id which it was set and firefox doesn't show at all

by msinfo (Sexton)
on Aug 21, 2013 at 01:43 UTC ( #1050271=perlquestion: print w/ replies, xml ) Need Help??
msinfo has asked for the wisdom of the Perl Monks concerning the following question:

hi, i am trying to use cgi::session, but no luck yet. index.html has form which gets user credentials, matches them with mysql databases values, and if right, then sets a session otherwise shows login.html
# create a new session my $session = CGI::Session->new() or die CGI::Session->errstr; print $session->header(); #setting session to expire in 1 hour $session->expire("+1h"); #further in page # logout option print "<a href='logout.cgi'>logout </a></br>"; # check option print "<a href='check.cgi'>check page</a>"
this page gives output properly, it gnerates session id, but when i click on check page link, it doesn't show me session info and i always get "no session" message.
# cgi page my $cgi = CGI->new; #print $cgi->header(); print $cgi->start_html(); print $cgi->p("hello"); print $cgi->cookie('CGISESSID'); # load session info my $session = CGI::Session->load() or die CGI::Session->errstr; print $session->header(); if ($session->is_empty) { print $cgi->p("no session"); } else { print $cgi->p("<b>session data loaded</b>"); print $session->name; print $session->id; print $session->is_expired; } print $cgi->end_html();
and this is code in logout.cgi
# Delete the session for good: my $session = CGI::Session->load() or die CGI::Session->errstr; $session->delete(); $session->flush(); print $session->header(-location=>'http://localhost');
what am i doing wrong?

Comment on ie with cgi::session not showing same session id which it was set and firefox doesn't show at all
Select or Download Code
Re: ie with cgi::session not showing same session id which it was set and firefox doesn't show at all
by Anonymous Monk on Aug 21, 2013 at 03:21 UTC
Re: ie with cgi::session not showing same session id which it was set and firefox doesn't show at all
by Anonymous Monk on Aug 21, 2013 at 16:21 UTC
      Thanks for being with me. Am i correct that you are saying, all above code worked fine at your system? How come I am getting two different results. 1. IE9 and Firefox showed started session id, but when clicked on check.cgi IE showed different session id, and Firefox showed none. 2. Both browsers returned, session->is_empty as true. when check.cgi ran. Could you please, share your compiled code, which shows results written on webpage. About debugging, I went through links mentioned on above post. Brian d foy's comments were useful. But I am confused because when I run scripts from command line mode, it doesn't shows any errors. (returns syntax ok) I am trying to retreive session info from cookie and param but no luck yet.

        Am i correct that you are saying

        I am saying you should employ the Dumpering debugging strategy cause I don't see no Dumpering output in your response

        Dumpering is debugging step number one

        Dumper your CGI object, Dumper your session object, Dumper whatever else thats important

        Basic debugging checklist item 4 ( Dumper )

        Then realize the problem, or show me so I can realize the problem for you

        print $query->escapeHTML( scalar Dumper( $query, $session ) )

        Could you please ...

        No thanks ; programming is a process, the only way to get a handle on it is to do these steps yourself;

        What you posted doesn't compile, which means you didn't run what you posted to figure out how this works -- that it is working --

        Which means you're probably trying to debug this problem in your larger code

        That is tough/hard way to go about it; you can read more about this scenario in Re^3: CGI::Session "cache" issue

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2014-07-25 09:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (170 votes), past polls