floridaflatlander Posted October 11, 2012 Share Posted October 11, 2012 (edited) I would have thought this would have been beat to death on here by now but I searched for "Check for cookies" and I didn't see this topic. On a site I'm making, users can't login without cookies inabled. // I have an included fucntion file and I have this near the top if (!isset($_COOKIE['AllowCookies']) OR $_COOKIE['AllowCookies'] != 'Yes') {setcookie("AllowCookies", Yes);} // To check to see if browser accepts cookies // then on the login page I have if ($_COOKIE['AllowCookies'] != 'Yes') {echo '<p style="color: red;">Sorry, your cookies are turned off. You must allow them in your browser to login. Thank you</p>';} I searched the web and came up with more verbose examples which makes me wonder if this is good enough or if I'm missing something. So my question is, will this do? Edited October 11, 2012 by floridaflatlander Quote Link to comment https://forums.phpfreaks.com/topic/269358-checking-if-cookies-are-allowed/ Share on other sites More sharing options...
premiso Posted October 11, 2012 Share Posted October 11, 2012 The best way to check for cookies is using javascript. There should be plenty of JS cookie checkers out there, where you basically set a cookie in Javascript, check for it in PHP, if that cookie is not there, they either have JS Disabled and or Cookies disabled. I have never really seen it done properly in PHP, because you have to do a page reload to attempt to read the cookie, where as JS there is no reload done. Quote Link to comment https://forums.phpfreaks.com/topic/269358-checking-if-cookies-are-allowed/#findComment-1384517 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.