如何删除特定的Cookie值? [英] how to remove specific cookie value?

查看:574
本文介绍了如何删除特定的Cookie值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序也有使用的浏览器Facebook和Twitter的登录和登录后自动保存的cookies。 我不得不退出Facebook的将要发生删除的Facebook的cookie值,但我不知道如何删除特定的Cookie。

In my app there are facebook and twitter login using browser and after login it stores cookies automatically. i have to logout facebook that will be happen to remove facebook cookies value but i don't know how to remove particular cookies.

如果我使用删除所有Cookie:

if i remove all cookies using:

CookieManager cm = CookieManager.getInstance(this);
cm.removeAllCookies();

但它会删除所有cookie值意味着它将退出既Facebook和Twitter这两个。

but it removes all cookies value means it will logout both facebook and twitter both.

我的问题是 - 如何删除特定的Cookie值

my question is -- how to remove particular cookie value.

感谢..

推荐答案

您应该使用 CookieManager.setCookie()键,设置cookie为空字符串。像这样的东西应该工作:

You should use CookieManager.setCookie() and set the cookie to the empty string. Something like this should work:

String cookieString = "cookieName=''";
cookieManager.setCookie(cookieDomain, cookieString);

在除了设置cookie值空,也可以通过在cookie字符串的过期值设置为在过去的一段时间过期饼干。例如:

In addition to setting the cookie value to empty, you can also expire the cookie by setting the 'expire' value in the cookie string to a time in the past. For example:

String cookieString = "cookieName=;expires=Mon, 17 Oct 2011 10:47:11 UTC;";

这篇关于如何删除特定的Cookie值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆