最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - How to delete all cookies for facebook.com? - Stack Overflow

programmeradmin2浏览0评论

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 0
Add a ment  | 

5 Answers 5

Reset to default 3

PHP 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

发布评论

评论列表(0)

  1. 暂无评论