PHP can't remove cookie that was set by JavaScript
cookies, javascript, php
Solution
You can't force the browser to delete the cookie file. You can, however, delete the contents of the cookie and expire it. Which is exactly what you're doing with your code above. I would probably tweak it slightly:
setcookie('myCookie', '', 1, '/'); // no need to calculate one hour ago.
Problem
Is it possible to remove cookie that was set on front via JS with PHP? I'm doing this: *FRONT (JS): ``` if ($.cookie('myCookie')) { console.log('Cookie.. :( '); } else { console.log('Yaay! No cookie!'); $.cookie('myCookie', '123'); } ``` BACK (PHP): ``` if (isset($_REQUEST['removeCookie'])) { setcookie("myCookie", "", time()-3600); unset($_COOKIE['myCookie']); } ``` Result: Seems like it's a mistery