Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I am having a problem getting these set/get cookie scripts to work with Firefox or any Mozilla browsers. I'm befuddled and would appreciate any suggestions.

setacookie.cgi
#!/usr/bin/perl use CGI; use CGI::Carp qw(fatalsToBrowser); $query2 = new CGI; $cookie = $query2->cookie(-name=>'TEST-COOKIE', -value=>'test cookie ', -expires=>'24h', -path=>''); print $query2->header(-cookie=>$cookie); print"<html> <body> <a href='http://www.yourdomain.com/cgi-bin/getacookie.cgi'>This is a l +ink</a> </body> </html>"; print $query2->end_html;
getacookie.cgi
#!/usr/bin/perl use CGI; use CGI::Carp qw(fatalsToBrowser); $cgi_query = new CGI; print $cgi_query->header; print $cgi_query->start_html('getacookie program'); print $cgi_query->h4('Your cookie name is...'); $testCookie = $cgi_query->cookie('TEST-COOKIE'); print "<PRE>\n"; print $testCookie; print $cgi_query->end_html;

Replies are listed 'Best First'.
Re: Problems getting cookies
by moritz (Cardinal) on Oct 14, 2010 at 06:38 UTC
    Your browser has a feature to show you all stored cookies. Does it show the test cookie after you visit the setacookie.cgi script?
    Perl 6 - links to (nearly) everything that is Perl 6.
      Yes, the cookie appears in the 'Cookie Manager'.
        Are the domains consistent, in terms of where the set/get cookie code is being executed? My guess would be yes, if they are running on the same server, but worth checking...
        Next step: look at the source of the generate HTML page - maybe your browser doesn't display something that's actually there.

        If that's not the case, use a network traffic analyzer like wireshark to see if the cookie is actually included on the request to the second script.

        Perl 6 - links to (nearly) everything that is Perl 6.
Re: Problems getting cookies
by Anonymous Monk on Oct 14, 2010 at 16:14 UTC
    I tried the scripts on a different server and the browsers on a different computer but still nothing. -- This is so bizarre.
A reply falls below the community's threshold of quality. You may see it by logging in.