Okay I'm having a heck of a time getting a cookie to set in Internet Explorer (the problem seems to occur on any version). I'm using CGI.pm to call the CGI::Cookie routines and I read somewhere that older versions of CGI.pm didn't do cookies correctly on IE so I upgraded to the latest version. Anyway, I know I've gotten this to work before. This isn't the actual code I'm working with but it does the same thing and gives the same error. (domain names were changed to protect the innocent)

#!/usr/bin/perl use CGI; use strict; my $cgi = new CGI; my %foo = (key1=>"value1",key2=>"value2"); my %from_cookie = $cgi->cookie(-name=>'foo'); if(%from_cookie) { print "Content-type:text/html\n\n"; print "<html><body>\n"; foreach my $key(keys %from_cookie) { print "$key = [$from_cookie{$key}]<br>\n"; } print "</body></html>\n"; } else { my $cookie = $cgi->cookie( -name=>'foo', -value=>\%foo, -expires=>'+1h', -path=>'/', -domain=>'somedomain.com', ); print $cgi->header(-cookie=>$cookie); print "<html><body>I have set the cookie</body></html>\n"; } exit;

The program I'm working on uses the hash as the cookie as this one does, but I also tested this just passing a single value to the cookie and got the same result: The cookie sets and works just fine on Netscape and Mozilla but on IE it doesn't set. I know I'm probably doing something dumb :) but this one just has me stumped.

Thanks in advance

Chris

In reply to Evil Cookies in IE by cfreak

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.