in reply to Re^2: Cookie->fetch problem
in thread Cookie->fetch problem

Hi: Round and round. Just can't recover a $sid from a cookie.

Tried count on the cookies and it returned 0 Still struggling with this hole in my program. There are three cookies associated with my site.

Fri Mar 10 12:31:32 2017 manage_users.cgi: keycount: '0' at /home/jalamior/www/httpsdocs/cgi-bin/lib/perl/manageusers.pm line 681.

my %cookies = CGI::Cookie->fetch; my $count = keys %cookies; warn("keycount: '$count'"); while(my($key, $value) = each %cookies){ Dumper \$key; Dumper \$value; if($key eq $sessionname){ $sid = $value; } }

Replies are listed 'Best First'.
Re^4: Cookie->fetch problem
by huck (Prior) on Mar 10, 2017 at 20:34 UTC

    they expired?

    if firefox
    tools->options->privacy->show cookies.
    look for your domain(s), press + to expand, look for cookie names.

    if you are running a separate test server, make sure you are looking at the right domain

      I have checked the cookies. They are in the correct domain.

      I will keep struggling with this. In the meanwhile I just the sid from the cookie into the $sid variable in the subroutine so I can keep working. V hange to 0 to get logged out.

      Best regards

        Need some really serious help here. This is text of email with screens shot I want to send. I cant find where you can attach images. If that is not possible, send me an email tultalk at hughes dot net and I will include picture.

        Issue:

        Recovering cookie data. Installed little program in site main page https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_cookie First click showed one cookie with no name of unknown origin that keeps appearing. Opened firefox options and looked at cookies. There were two. The blank and the CGISESSID my program installs I deleted the blank and then clicked the button for the script and it showed no cookies. Opened firebug and looked at cookie panel and the CGISESSID was there. This is really bizarre.

Re^4: Cookie->fetch problem
by Anonymous Monk on Mar 11, 2017 at 01:36 UTC

    Well,

    I think its time to show a complete program

    Or get some hands on help

    Some problems cannot be debugged piecemeal , conceptual holes don't allow it

      Hi:

      The problem is in the tiny isolated subroutine below. This code is from cookie.pm

      sub GetUserSessionCookie { warn("Entered GetUserSessionCookie Sessionname: '$sessionname'"); + # fetch existing cookies from cookie.pm CGI::Cookie - Interface to + HTTP Cookies my %cookies = CGI::Cookie->fetch; my $id = $cookies{'ID'}->value; my $sid = $id; warn($sid); $sid = 0; #for testing the rest of program. If I put in valid SI +D from #cookie recognizes user as logged on. return $sid; }

      The error returned:

      Can't call method "value" on an undefined value at /home/jalamior/www/httpsdocs/cgi-bin/lib/perl/manageusers.pm line 674.
      

      Is that error because there is no cookie->id string recovered by the call or a problem with the call itself?

      When I log in to https://www.jala-mi.org/httpsdocs/index.html

      Firebug cookies shows

      CGISESSID=16c11ce44ef8ffcfe6a5f0d74e4e0860; expires=Sun, 19 Mar 2017 00:47:22 GMT; path=/cgi-bin; domain=.www.jala-mi.org; Secure

      Opening the edit dialog under Firebug shows cookies.edit.expire.label as the date/time the cookie was created and when I click Ok, the cookie disappears.

      Log in again and new cookie with new date/time of creation in Firebug.

      Don't know what this is.

        There is no cookie named ID, i doubt there is even a cookie named CRESSIDA CGISESSID in there.

        Did you ever read Re^9: Cookie->fetch problem? pay attention to the part after "but i just figured out your problem"

        Edited to add:

        your test should probably look like this

        my $id=0; if ($cookies{'CGISESSID'}) { $id = $cookies{'CGISESSID'}->value; }
        but with the path that is set on that cookie you showed no cookies will be returned if you go to https://www.jala-mi.org/httpsdocs/index.html