0

I by mistake generate one cookie. which is now affecting my website. it generates in all the path of my website. because I set it up in a header file.

Now I want to delete that cookie once for all the paths.

setcookie('PHPSESSID','xyz',time()+800000);

I can able to delete only one cookie which set on path / but I can't delete all other cookies which set on different paths from logout.php file

Nirav Joshi
  • 2,924
  • 1
  • 23
  • 45
  • Possible duplicate of [How do I delete PHPSESSID on client computers](https://stackoverflow.com/questions/33517997/how-do-i-delete-phpsessid-on-client-computers) – rkeet Jan 08 '19 at 09:14
  • @rkeet i tried the solutions but not working properly. i can only delete the cookie which is in path `/` i also wan to delete all cookies which are on different paths – Nirav Joshi Jan 08 '19 at 10:12

1 Answers1

0

When deleting a cookie you should assure that the expiration date is in the past, to trigger the removal mechanism in your browser.

setcookie('PHPSESSID','',time()-3600);
  • i already mentioned that i can able to delete the cookie which in path `/` but i want to delete all the cookies which are on different paths. like `/abc`, `/xyz/123` etc – Nirav Joshi Jan 08 '19 at 10:11
  • You can not get the cookies path from the user browser. For example, you can use your routing table or your sitemap to find cookies to delete. – Alessandro Romeo Jan 08 '19 at 10:38