in reply to Cookies Not Getting Set First Time

Your not seting the -domain=> It's not set automaticaly.

Update: My bad. It is set automaticaly. Terrible. I must be tired today.

I'm not sure if your just checking or the presence of the cookie object but you need to use $cookie{$_}->value if you want the value of the cookie.

Try just printing out the keys of the cookies you do receive. If you don't get any try setting the domain to be generic like .domain.com instead of a full one.

Also, why are you setting two?

BMaximus

Update (again): Cowards abound on the board again. A -1 for me and not a reason why nor a correction. Don't vote down if you can't post an answer.

Replies are listed 'Best First'.
Re: Re: Cookies Not Getting Set First Time
by Anonymous Monk on Jul 12, 2001 at 23:33 UTC
    Ah. Looks like I'm not getting enough sleep either. Allow me to clear up a couple of things about the code I posted for the benefit of everyone trying (very kindly!) to help me out.

    First, the reason that I was setting two cookies (actually, the same cookie twice) was that after things didn't work, I was hoping that maybe if I just set the cookie twice I could having to run the whole script twice. I meant to change it back to just a single cookie before I posted the code, but obviously, I forgot. =)

    Secondly, the setting code and the fetching code were indeed run in seperate scripts, which were run several seconds apart...i.e. I ran the setting code, took a moment to look at some output, then typed the URL for the fetching script and ran it. So the problem isn't a timing issue. Good call though, to those who suggested that might be it

    After working on the code a little more, I found a solution: the setting code works fine the first time IF I don't use CGI::Cookie. Instead I just do:
    print"Set-Cookie: botLogin=$username:$trueName:$Hash\n"; print "Content-Type: text/html\n\n";
    Instead of:
    my $cookie = $cgi->cookie( -name=>'botLogin', -value=>"$username:$trueName:$Hash"); print $cgi->header(-cookie=>[$cookie,$cookie]), $cgi->start_html(-title=>'Login');
    Try as I might, I could never get it to work on the first run using CGI::Cookie. Any thoughts on why?