Jump to content

No Cookie Redirect


kool_samule

Recommended Posts

Hi Chaps,

 

Quick question on this one, I've got a <noscript> tag in my HTML to check to see if Javascipt in enabled, but how do you check to see if cookies are enabled?

Is there HTML code / PHP function, or do you simply try to set a cookie and redirect on failure to read the cookie you just to to set?

 

Cheers

Link to comment
Share on other sites

Hi there Kool_samule,

 

To check for this option, you would try to set a cookie, but place it in a if clause, as the function itself returns a bool therefore you can see if the function was set in the first place ;)

 

if(setcookie("cookieName", "cookieValue", time()*60*60*24), "/")){

//cookie was set

}else{

//cookie was not set

}

 

Hope this helps you ;)

 

Cheers,

Rw

Link to comment
Share on other sites

No, that won't work either. Cookies are sent to the server upon every request. Because you set that cookie after the request was made the cookie won't populate the $_COOKIE super-global until the next request of the page.

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.