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