Jump to content

[SOLVED] Problem: Cookies enabled or not?


Recommended Posts

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.