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

I'm having trouble setting & retrieving cookies with WindowsXP. I've setup a test server on my computer to develope & debug new code, before using it on my website.

To set a cookie, I use:
#!c:/perl/bin/perl -wT use CGI; use CGI::Carp qw(fatalsToBrowser); use strict; my $foo = new CGI; my $id_value = 123; my $var = 'someString'; my $cookie_id = $foo->cookie(-name => 'id', -value => "$id_value", -expires => '+18h', -path => '/'); my $cookie_var = $foo->cookie(-name => 'something', -value => "$var", -expires => '+18h', -path => '/'); print $foo->header(-cookie => [$cookie_id, $cookie_var]); print "<A HREF=\"check_cookie.cgi\">Check Cookie</A>\n";
To check to see if the cookie was set, I use the following script (check_cookie.cgi):

#!c:/perl/bin/perl -wT use CGI; use CGI::Carp qw(fatalsToBrowser); use strict; my $foo = new CGI; print $foo->header; my $id = $foo->param('id'); my $var = $foo->param('something'); print "$id<BR><BR>$var";
The problem is that the cookie isn't being set. It sets fine on the machine that my website is running on (a Linux box), but the cookies don't seem to set on the computer that I'm attempting to code & test on.

Can anyone offer me some advice/help solving this problem? It would be MUCH appreciated.

System info:
I've setup apache, MySQL, phpMyAdmin and PERL on my computer using PHPTriad. I've upgraded phpMyAdmin to the latest version, and have installed a full version of ActivePerl that I use, instead of the PERL installation that came with it. All this is being run on WinXP. All is functioning fine, except for the cookies.

Steny

Replies are listed 'Best First'.
Re: Setting & Retrieving cookies on WindowsXP problem...
by Abstraction (Friar) on May 02, 2003 at 01:41 UTC
    In check_cookie.cgi, instead of:

    my $id = $foo->param('id'); my $var = $foo->param('something');

    Try:

    my $id = $foo->cookie('id'); my $var = $foo->cookie('something');
      *smacks forehead*

      Stupid mistake on my part. What I was actually attempting to do is find out if it was cookies or CGI::Session that is messing up, and now maintaining user info, etc. Must be the session that is acting up, not cookies.

      Thanks for the help.