Jump to content

[SOLVED] How Can I Detect if a User's Cookies are Disabled?


Recommended Posts

Yes. Make a cookie. Then see if that cookie exists. If not, he has it disabled. If so, he has it enabled. You are welcome.  :D

 

Great!

 

So it can be done.

 

I'm guessing that it has to be done with PHP. Do you know of any scripts that I can refer to?

I'm guessing that it has to be done with PHP.

 

You don't have to use PHP, almost any web programming/scripting language should have the ability to manipulate cookies, including JavaScript. Of course if they have cookies disabled, I would have thought they'd more like the kind of user to have JS disabled as well.

 

In addition to that tutorial you may want to take a look at the PHP manual for setcookie, for a more thorough explanation.

Yes. Make a cookie. Then see if that cookie exists. If not, he has it disabled. If so, he has it enabled. You are welcome.  :D

 

So how do you distinguish between a new user (thus without a cookie) or a person with cookies disabled?

Excellent feedback, guys.

 

Thank you!

 

It seems that the only way to do it is to redirect the user to the same page after setting the cookie. Is that correct? Is it even possible?

 

How do I go about redirecting to the same page?  :shrug:

That would create an infinite loop, in the case that cookies are not set, unless you also include a get param that you check.  To redirect is no different than any other type of redirect -- you have the http header location method or a meta refresh.  As for getting the current page, there's the really helpful $_SERVER['PHP_SELF'].

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.