如何禁用webview 的cookie和缓存
1个回答
展开全部
根据自己需求用之前,全部清理一次或选择性清理
全部清理:
NSHTTPCookie *cookie;
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [storage cookies]) {
[storage deleteCookie:cookie];
}
或 选择性清理:
NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];
NSArray *cookieAry = [cookieJar cookiesForURL: [NSURL URLWithString: @"http://www.baidu.com"]];
for (cookie in cookieAry) {
[cookieJar deleteCookie: cookie];
}
全部清理:
NSHTTPCookie *cookie;
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [storage cookies]) {
[storage deleteCookie:cookie];
}
或 选择性清理:
NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];
NSArray *cookieAry = [cookieJar cookiesForURL: [NSURL URLWithString: @"http://www.baidu.com"]];
for (cookie in cookieAry) {
[cookieJar deleteCookie: cookie];
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询