删除 cookie UIWebView

Delete cookies UIWebView(删除 cookie UIWebView)

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

问题描述

如何在 UIWebView 中删除 cookie?这段代码:

How to delete cookies in UIWebView? This code:

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

删除 cookie,但是当我重新启动我的应用程序时,NSHTTPCookieStorage 中有相同的 cookie.有时这段代码有效,但我想让它每次都有效.如何解决这个问题?

deletes cookies but when I restart my application, there are same cookies in NSHTTPCookieStorage. Sometimes this code works, but i want to make it work everytime.How to solve this problem?

推荐答案

试试这样的:

NSHTTPCookieStorage* cookies = [NSHTTPCookieStorage sharedHTTPCookieStorage];
        NSArray* facebookCookies = [cookies cookiesForURL:
                                    [NSURL URLWithString:@"http://login.facebook.com"]];
        for (NSHTTPCookie* cookie in facebookCookies) {
            [cookies deleteCookie:cookie];
        }

这篇关于删除 cookie UIWebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:删除 cookie UIWebView

基础教程推荐