I want to know whether user has blocked cookies. I have googled for the solution in php. I have found the solutions to create a cookie and redirect to another page and then check the cookie. When I started thinking I have came across this solution
I am not sure if this method is harmful or not secure. Can anyone explain me if this method can be used or not
<?php session_start();
if(!isset($_COOKIE['PHPSESSID'])) echo 'cookies are disabled, set cookies';
I have read session_start()
creates a cookie on clients system to keep track of clients browser which is sent through headers for every http request and its key is PHPSESSID
If user blocks cookies in his browser session_start()
cannot create the cookie file with the key PHPSESSID
nor the headers are sent.
So understanding this I have found the above solution and it works, tested on FF, Chrome, >=IE8.
Let me know if this is method have any downsides. Thanks