Amanjot Singh
Amanjot Singh

Reputation: 178

How to delete the same cookie in php from two different path

My problem is that I want to delete the cookie from the page which is in the different directory from the page who sets the cookie but due to the path restriction PHP is not deleting the cookie. Has anyone any solution?

Upvotes: 2

Views: 1464

Answers (1)

Tasos Bitsios
Tasos Bitsios

Reputation: 2799

When you set and delete the cookies, pass the same path:

setcookie('cookie_name', "SOME_VALUE", time()+3600, '/');   //to set

setcookie('cookie_name', "", -1, '/');            //to unset

http://php.net/manual/en/function.setcookie.php

http://www.phpbuddy.com/article.php?id=12

Upvotes: 1

Related Questions