Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Cookie->fetch problem

by Eily (Monsignor)
on Mar 09, 2017 at 15:53 UTC ( [id://1184040]=note: print w/replies, xml ) Need Help??


in reply to Cookie->fetch problem

This warn("GetUserSessionCookie SID: $sid"); posts to error log: GetUserSessionCookie sessionname: ''
The message inside the warn and the actual log are distinct: one contains "SID", the other "sessionname". The warning message that does contain "sessionname" is commented out in your code. So either you are not modifying the file that is actually executed, or you gave us the wrong code.

Replies are listed 'Best First'.
Re^2: Cookie->fetch problem
by tultalk (Monk) on Mar 09, 2017 at 16:04 UTC
    I copied the code at the wrong time. I have commented that in and out. Also where I set $sid to 0 was for testing also. I did set the $sid = '12ba7ce0cfeeae8e8a934af6724910e9'; which I copied from the cookie I am interested in and it proceeded to assume I was logged. The calling code just check ne 0 so anything ne 0 would have the same effect
    sub ProcessLoginRequest { my ($query) = @_; my $status = 0; # $sessionname = 'CGISESSID'; # my %cookies = CGI::Cookie->fetch; # my $sid = $cookies{$sessionname}->value; my $sid = GetUserSessionCookie(); warn("ProcessLoginRequest Query: '$query'"); warn("ProcessLoginRequest SID from cookie: '$sid'"); #Check if it got valid return from fetch cookie if ($sid ne 0){ $status = 1;

    But later I compare against the stored session ID.

    #--------------------------------------------------------------------- +---------- # FUNCTION: OpenSession($dbh, $sid) # Opens existing session or creates new depending on $sid #--------------------------------------------------------------------- +---------- sub OpenSession{ my ($dbh, $sid)= @_; $session = new CGI::Session("driver:MySQL", $sid, {Handle=>$dbh, Lo +ckHandle=>$dbh}); return $session; }
    Thanks

      OK. Then here's what you can do:
      1) Fix your original post's formatting (ie: add <p> tags). See Markup in the Monastery
      2) Add use Data::Dumper; at the top of your file, and turn warn %cookies; into warn Dumper \%cookies;, you'll get a clearer view of what fetch() returns.

        I did use the tags on the text. I guess you mean at every paragraph etc.

        Where does data dumper dump data?

        As a side issue, I looked at cookies in the firefox options and it showed three on my main page including the CGISESSID

        I then looked at the cookies with the Firebug cookie panel and there were only two and unrecognizable in relation to the Firefox Options cookie viewer. Is there something obvious zi am missing?

        Thanks

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-20 01:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found