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

I have code that looks something like this:
sub isValid{ my $Cookie = new CGI::Cookie(-name=>'login', -value=>1, -expires = +>'+2m'); print header(-cookie=>$Cookie),start_html, a({-href=>'http://www.mysite.com/devel',-target=>'_top'},div({ +-align=>'center'},"Activate Session")), end_html; exit; }

Problem is that it only seems to work on a few browsers. It succeeded on IE5 as well as mozilla 1.0(linux) and Netscape 6.2(windows). On IE6, and Konqueror, it appears that the cookie wasn't passed(i have a php script that gives different output if the cookie is not found, and i double checked the folder my cookies go into). Is there a better way to set cookies that I have missed? Any suggestions on a better way to set up session data that can be read by cgi and php applications would also be appreciated.

Replies are listed 'Best First'.
Re: cookies are not set consistantly
by rdfield (Priest) on Jul 03, 2002 at 13:56 UTC
    I had problems 'use'ing CGI and CGI::Cookie in the same script - worked OK when one of them was removed (ie use the cookie handling in CGI.pm or hand roll your own HTML).

    rdfield

Re: cookies are not set consistantly
by caedes (Pilgrim) on Jul 03, 2002 at 20:55 UTC
    Rather than sitting around hypothesizing about the possible results of your program, the best approach would be to actually view the headers that the program is sending.

    Regarding your code, there is absolutely no reson to use CGI::Cookie when you are already using CGI.pm. the -cookie attribute of the header method of CGI expects a simple text version of the cookie and is meant to work with CGI->cookie().

    -caedes