Nolongerused3921 Posted May 1, 2008 Share Posted May 1, 2008 I'm trying to write a basic function to check whether or not the user has cookies enabled (So I can decide if I want mod_rewrite turned on or not, among other things)*, but I'm having some problems. public function CookiesAllowed() { //If cookie allowed exists, return 1... If not, try to set it for 2 weeks - if fails, return 0... If successful return 1 return (isset($_COOKIE['allowed'])) ? 1 : setcookie("allowed", "true", time()+60*60*24*30); } I'm using IE7.0 to test, I set it to ask me every time a cookie is set, and have the cookies array output using print_r... Even if I deny the cookie, and it doesn't show in the array (After several refreshes), this function still returns 1. Setcookie should return 0 if the cookie wasn't set properly, but it always returns 1 for some reason - any ideas why? Any way I can fix this? *I'd rather not have to edit all of my mod_rewrite rules to have SESSID on the end, so I just let PHP handle it and turn mod_rewrite off if the user isn't allowing cookies. Quote Link to comment Share on other sites More sharing options...
Nolongerused3921 Posted May 1, 2008 Author Share Posted May 1, 2008 Didn't read through the setcookie page on php.net, turns out it only returns false on failure, and is not based on whether or not the user has accepted it. 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.