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

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

Replies are listed 'Best First'.
Re^5: Cookie->fetch problem
by tultalk (Monk) on Mar 11, 2017 at 01:35 UTC

    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.

        Here is a small perl cookie test script. Put this cookietest.cgi in the same folder as manage_users.cgi. Access with browser and click the create button several times to see cookies created. Then repeat press the refresh button to see them expire after 20 seconds and disappear. This should show whether the problem is with your script, browser or server.

        #!/usr/bin/perl # cookietest.cgi use strict; use CGI ':standard'; use CGI::Cookie; use Data::Dumper; my $time = scalar localtime; my $cookie; if ( param('action') ){ $cookie = new CGI::Cookie( -name => (sprintf "TESTCOOKIE_%05d",rand(10000)), -value => $time, -expires => '+20s' ); CGI::delete_all(); print redirect( -cookie => $cookie ); } my $JS =<<EOJ; function display_ct() { var x = new Date() document.getElementById('ct').innerHTML = x; } EOJ print header( -cookie => $cookie ), start_html( -title => "cookietest.cgi", -script=>$JS, -onLoad=>"display_ct();" ), h2("Cookie Test"), h3("Server time is : $time"), h3("Client time is : <span id='ct' ></span>"); print start_form( -method => "POST" ); print submit("action","create cookie"); print submit("refresh","refresh"); print end_form; my %cookie = CGI::Cookie->fetch; my $count = keys %cookie; print h3("There are $count cookies"); print pre( Dumper \%cookie ),end_html;
        poj

        First regarding the cookie with no name, read Re^4: Cookie->fetch problem near the bottom after "and note that if i run". you put it there once when you passed back a cookie without setting the name to CGISESSID, and you may keep doing it too.

        clicked the button for the script and it showed no cookies.

        you are not clear but i think you are saying the the script showed no cookies returned. I think this is a mismatch with your path/domain and maybe secure that the cookie should be returned to. look closely at the http:://some.domain.com/ file you are going to, compare that to the address the cookie is stored under. i have cookies stored for both m.staples.com and staples.com. The next part is the path. if the cookie says the path is / then it will be sent back to the server for any page, but of the cookie says the path is /cgi-bin it will only be sent back if you are going to http:://some.domain.com/cgi-bin pages. you were setting the domain when you returned the cookie, if you didnt get it right when you set it it wont get returned. Another thing you were setting wad the secure option. cookies with the secure option only get returned if you have a secure (https/SSL connection. if you are now going to a plain http: address or the SSL negotiation is failing the browser will not return the cookie.

        This page https://www.nczonline.net/blog/2009/05/05/http-cookies-explained/ seems to explain things pretty good.