I am working on a script which allows for a switch between mobile and desktop view of my website. The way I am getting it done is by placing a cookie on the system when the user click on 'Desktop' and deleting the cookie when the user clicks on 'Mobile'.
The system works the first time around with the cookie being placed and the redirect takes place.My script also read the cookie on index.php to serve the desktop view if the cookie is present. When the user clicks again on 'Mobile', I delete the cookie and the run the USER AGENT check.
The second time around, when I click on 'Desktop' link, the cookie is not set and the script fails to execute. What could be a possible error for this?
Thanks for your time
EDIT: I am creating the cookie by setcookie("mobile", "web",time()+31536000, "/");
Deleting the cookie by setcookie("mobile", "",time()-60, "/");
From the HTTP Headers I can see the Set-Cookie parameter being passed the first time the script executes, but after I delete the cookie and try again, the setcookie parameter is not passed.