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

I've got a problem that I can't find any reason for. I've got a very simple message board for my site and it uses cookies to store user names and hold unix times for post times. Everything works fine on PC's in all browsers, but on the Mac (both IE and Mozilla) the cookies don't store properly.

The cookies store about 50% of the time but they disapear the next time the script trys to store a cookie. I don't know if this is a common problem. Is there a max length for cookies on the mac? Do they read expiration dates differently?
Any ideas? He're a snipit of the code.
use CGI qw/:standard/; use CGI::Carp 'fatalsToBrowser'; use CGI::Cookie; my $cname = new CGI::Cookie(-name => '2930ForumCookie', -value => "$in{name}|$time|$oldtime", -domain => '.2930online.com', -expires => "$exp"); print "Set-Cookie: $cname\n"; print "Content-type: text/html\n\n";

$exp is set by a form variable and is either +3M or -3M depending on the setting. I always leave it checked (setting it to +3M). $time is just current unix time and $oldtime is the last post time. This is the only place cookies are set though they are read by several scripts.

Thanks in advance for any help.

Replies are listed 'Best First'.
Re: Cookies and the macintosh
by Cody Pendant (Prior) on Aug 29, 2002 at 09:55 UTC
    Another question, why this:
    print "Set-Cookie: $cname\n"; print "Content-type: text/html\n\n";
    Instead of just this:
    print header(-COOKIE => $cname);
    as you're using CGI anyway?
    --
    ($_='jjjuuusssttt annootthheer pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;
Re: (nrd) Cookies and the macintosh
by newrisedesigns (Curate) on Aug 29, 2002 at 06:13 UTC

    I looked online via the oracle, but found little. I don't have a Mac, so I can't test anything until I'm back at school and use their Macs.

    You can always take a look at the Netscape Cookie Specifications and see if there's anything that might throw off Macs. Also, browse through the ADC for information about Macintosh browsers. I searched for terms relevant to "cookies", but found nothing.

    Good luck to you. If you could, elaborate on why half the time cookies remain set and half they are lost.

    John J Reiser
    newrisedesigns.com

Re: Cookies and the macintosh
by Cody Pendant (Prior) on Aug 29, 2002 at 09:50 UTC
    There is a known bug in some versions of IE on Mac which causes cookie problems if you don't set a path as well as all the other options for a cookie. I can't give you a cite for it right now, but I'll find one.

    I'm surprised to hear it's happening in Mozilla though, and I'm surprised to hear it's happening intermittently.

    The good news is IE5 on Mac has got very very detailed cookie management options. Go into the preferences and you can see all the details. Set the prefs to "ask for each cookie" and see what comes up.
    --

    ($_='jjjuuusssttt annootthheer pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;
      The intermittent thing is whats baffeled me too. I've tried to find some pattern to it, but I haven't been able to.

      Also, I used to have it set up to set 3 cookies, one for each variable, and it would set different cookies at different times. Sometimes the name cookie would be saved, some times one date or the other, sometimes 2 cookies, sometimes none, and rarely all 3.

      I'll try setting a path and see if that helps. I only have access to mac's at work so I won't be able to test it until then.

      I should also note that the same problem occures in OS 9 and OS X.