I need to delete all cookies created after Facebook login.
using PHP I use setCookie('CookieName')
method without any value. But It didn't work.
Is there any way to delete all cookie for a website by using PHP/JavaScript?
I need to delete all cookies created after Facebook login.
using PHP I use setCookie('CookieName')
method without any value. But It didn't work.
Is there any way to delete all cookie for a website by using PHP/JavaScript?
Share Improve this question edited Nov 30, 2012 at 9:57 j0k 22.8k28 gold badges81 silver badges90 bronze badges asked Nov 30, 2012 at 9:45 user1862780user1862780 511 silver badge5 bronze badges 05 Answers
Reset to default 3PHP on your server cannot alter cookies that are set by facebook. - only the cookies set by your domain. Same issue with JavaScript running on your page.
Are the cookies really Facebook's? or one's set by the SDKs on your domain?
Security policy will not allow you to manage other sites cookies, so there is now way to delete facebook. cookies from your script.
Correct me if i'm wrong.
Sorry, but I don't think its possible to do what you are trying to do. You mess around with (set, alter or delete) cookies from your own domain. So if you are serving stuff from anywhere other than facebook, you will not be able to effect the facebook cookies.
Here is another stackoverflow thread on the same issue Cross domain cookies
To delete a cookie you have already set on your own domain you can use:
setCookie('CookieName', '', time()-3600);
From the manual:
When deleting a cookie you should assure that the expiration date is in the past, to trigger the removal mechanism in your browser.
See the answer here
// unset cookies
if (isset($_SERVER['HTTP_COOKIE'])) {
$cookies = explode(';', $_SERVER['HTTP_COOKIE']);
foreach($cookies as $cookie) {
$parts = explode('=', $cookie);
$name = trim($parts[0]);
setcookie($name, '', time()-1000);
setcookie($name, '', time()-1000, '/');
}
}
http://www.php/manual/en/function.setcookie.php#73484