问题描述
我有一个 UIWebView,我不希望它存储 cookie,所以在加载 webview 之前我会这样做:
I have a UIWebView, and I don't want it to store an cookies, so just before the webview is loaded I do:
NSArray* cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies];
for (NSHTTPCookie *cookie in cookies) {
[[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
}
检查 cookie 的计数为 0,因此它们都被删除.但是当我去 stackoverflow 时,它仍然可以识别我的 Google 帐户并让我登录.这是怎么发生的?我认为它与 cookie 一起使用?
Checking the count of cookies is 0 so they are all deleted. But when I go to stackoverflow it still recognizes my Google Account and logs me in. How does this happen? I though it worked with cookies?
推荐答案
我不得不处理完全相同的问题,我找到了两种方法来处理这个问题.我首先注意到 cookie 会(有时)在奇怪的时间设置(奇怪的行为,尤其是 ios 4.0).
I had to deal with the exact same issue and I found 2 ways to deal with that problem. I first noticed that cookies get (sometimes) set at weird times (Strange behaviour especially with ios 4.0).
- 在用户浏览网页后立即删除 Cookie 通常无法获得预期的结果.
然后我集成了一个持久的手动标志,该标志在注销"(也就是清除所有 cookie/删除其他用户数据)操作时设置为 True.在下一次登录(也就是基于用户登录的操作)时,我再次清除了 cookie(与您在代码发布中所做的相同).
I then integrated a persistant, manual flag that was set True on a "logout" (aka clear all cookies / delete other user data) action. upon the next login (aka user-login-based action) I cleared the cookies again (the same way you did it in your code-post).
后来我发现,听 NSHTTPCookieManagerCookiesChangedNotification 然后删除 cookie 也很有效.
Later I found out, that listening to NSHTTPCookieManagerCookiesChangedNotification and then deleting cookies worked really well too.
希望我能帮上忙.
这篇关于UIWebView 中的 Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)