如何在 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!