RE: [PHP] Repeat : I'm Living in cookie hell....

From: Date: Sat, 12 May 2001 20:17:19 +0000
Subject: RE: [PHP] Repeat : I'm Living in cookie hell....
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-52588@lists.php.net to get a copy of this message
Thanks for your reply. Unfortunately, the problem is not in getting the code to execute - I know it is for two reasons: 1) the setcookie(...) is being triggered because I have cookie warnings turned on in the browser, and it warns me that a new cookie is being received.... and it shows me the expected content of the cookie 2) the reloacation via the header is occuring as expected. It's just that the cookie being set isnt being retained on the browser.... (oh - and as a side note, there would only ever be 1 match for the returned mysql result... which is why I didnt loop through them... there's either a row returned, or not... and if not, then the rest of the code that wasnt included in the msg handles that situation) What I'm wondering though, is.... in the page which sets the cookie ok, there is no redirection.... it executes: setcookie("YONKAMEMBERID",$insert_id,time()+31536000,"/",$PHP_HOST); inline, and then displays the page. In the page which doesnt set the cookie, there is redirection occuring setcookie("YONKAMEMBERID",$login_id,time()+31536000,"/",$PHP_HOST); Header("Refresh: 0;url=/"); It's the exact same code -- just a different variable setting the value, and the header call afterwards. (though even when I comment out the header(..) it still doesnt work.) Something just isnt right somewhere. Is it the path of the script being exeuted that's causing something strange to occur?? I really am at a loss.... > Hello Scott, > > I took a look at your code, and have a solution for you. > > Here's the code: > > while ($row = mysql_fetch_array($result) ) > { > if ($row["memberid"] == $login_id) > { > // your code here :-) > } > } > > > > > $row = mysql_fetch_array($result); // Get one row of > data only *BAD* > > if ($row[memberid] == $login_id) { > > // [...] > > } > > > > the path of the cookie to be the root under both instances, > it should be > > trying to set the same cookie, right? > > correct, but this only works if the first array returned is > equal to the > login_id. since you are returning only the first row of your database > table, you never make it to the memberid that you're hoping > is there -- > assumming that it is there. > > Train harder! > > regards,barce > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > >

« previous php.general (#52588) next »