mhoctober Posted March 31, 2006 Share Posted March 31, 2006 Guys...I am attempting to test for the existence of a cookie and take appropriat actions...however, this code ALWAYS displays "Cookie Set"when I load it into my browser.I an attempt to have it execute the Else section I have...- changed the name of the cookie on the If line- deleted cookies via IEBut alas - its always displaying "Cookie Set"is there something I am missing here? <?phpif (!isset($_COOKIE["ckBeenHere"])){echo "Cookie Set";}Else{echo "Cookie Not Set, Setting Cookie and Updating Counter";setcookie ("ckBeenHere", time()+43200); // will expire in 12 hours} Quote Link to comment Share on other sites More sharing options...
azuka Posted March 31, 2006 Share Posted March 31, 2006 Youre using the wrong code. Change it to. [code]if (isset($_COOKIE["ckBeenHere"])){echo "Cookie Set";}else{echo "Cookie Not Set, Setting Cookie and Updating Counter";setcookie ("ckBeenHere", time()+43200); // will expire in 12 hours}[/code]You were checking if it had been set and echoing if it wasn't instead of the opposite Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.