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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.