in reply to Re: Crashing Cookie Code
in thread Crashing Cookie Code

I've done some extra checking and:

1) My browser definetly receives the cookie.
2) The second script receives no cookies. I used the Dumper thing, I've also tried a foreach (keys %cookies) loop, and I've even tried send a scalar value (instead of the hash).

Is there a way to check if it's a problem with the server config, or if the browser isn't sending the cookie back? (Unlikely, since I've tried it from Linux and Windows using Netscape and IE - both of which behave fine at other cookie-enabled sites.)

P.S. Code now looks like this:

%cookies = fetch CGI::Cookie; print "<br>Fetched Cookie<br>\n"; print Dumper %cookies; # Prints nothing!!! print "<br>Just dumped cookie hash.<br>\n"; if(%cookies ne undef) { # We get here, so %cookies is defined print "Keys: "; foreach (keys %cookies) # Finds no keys!!! { print; print " "; } print "<br>---<br>"; if($cookies{'ID'} ne undef) { # Tried as a plain hash, hashref, with and without '->value' my $hashref = $cookies{'ID'};#->value; $username = $$hashref{'username'}; $password = $$hashref{'password'}; print "Username: $username<br>"; print "Password: $password<br>"; } else { # We keep ending up here!!!! print "Damn!<br>\n"; } }

Replies are listed 'Best First'.
Re: Re: Re: Crashing Cookie Code
by Masem (Monsignor) on Jun 19, 2001 at 17:37 UTC
    Ok, at this point, I'd drop back to CGI.pm and try using the raw_cookie() function to just see if anything is getting through (you'll have to create a CGI object to use this). raw_cookie's output will be rather messy, but it should have at least something if the cookie is being sent.
    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
PROBLEM FIXED
by quill (Initiate) on Jun 19, 2001 at 19:42 UTC
    I'd like to thank everyone for their help - the problem is now fixed. For the sake of others with this problem, here's what was going on:

    For some reason, while the browser was receiving a Cookie (I turned on the "Warn Me" option), it wouldn't actually save it when I tried to send a Hash. I fixed that by sending 2 cookies, each with a simple scalar value.

    However, the other problem was that while the CGI docs claim that if the "path" parameter is left out it gets set to "/" (allowing all your scripts access to the cookie), I found that it actually set it to the full script path (which didn't work for me since I was using 2 scripts). I had to manually set to path to "/".

    These were both solutions I tried before posting, but I guess that it wasn't at the same time. And while no one actually literally suggested this solution, some of the advice prevented other bugs from cropping up. Thanks again!