如何在UIWebView中清除Cookies

时间:2012-05-16 11:02:08

标签: iphone ios cookies uiwebview

我正在使用UIWebView加载URL。我想知道如何清除那里的Cookies。

2 个答案:

答案 0 :(得分:15)

您可以浏览cookie jar中的每个cookie并将其删除。

How to delete all cookies of UIWebView?

NSHTTPCookie *cookie;
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [storage cookies]) 
{
   [storage deleteCookie:cookie];
}

答案 1 :(得分:1)

NSHTTPCookie *cooki;
NSHTTPCookieStorage *data = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cooki in [data cookies]) {
   [data deleteCookie:cooki];
}