I've been thrashing around the monastery (and Google, and a few other programing sites) for a few days trying to figure out why my code for setting a cookie works in one cgi script but not another.
This one works (i.e. it sets the cookie):
# Process form and set cookies
my ($cat) = param('butCat');
my ($typ) = param('txtTyp');
my ($to_set) = cookie(-name => 'cat',
-value => $cat,
-path => '/',
);
my ($to_set_a) = cookie(-name => 'bus_com',
-value => $typ,
-path => '/',
);
print header(-cookie => [$to_set, $to_set_a]);
This one doesn't (i.e. no cookie):
$i = 0;
while (@record[$i]){
# Set adv_cookie
$cgi = CGI->new;
$adv = @record[$i];
my ($to_set) = cookie(
-name => 'adv',
-value => $adv,
-path => '/',
);
print header(-cookie=>[$to_set]);
$i=$i+1;
my (@args) = ($path."advlst.cgi");
system(@args);
I have checked for the cookie manually on the browser as well as using cookie('adv') in the script called using system. I'm picking that I've done something really simple wrong but I can't for the life of me see how this is different from a dozen or so scripts I have seen online (or from my first script).
Any suggestions?
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.