如果应用终止,则删除的NSHTTPCookie返回 [英] deleted NSHTTPCookie returns if app is terminated

查看:54
本文介绍了如果应用终止,则删除的NSHTTPCookie返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用一些代码删除所有cookie后:

After using some code to delete all of the cookies:

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

如果您在一段时间内继续使用该应用程序,则cookie保持删除状态.但是,如果您此后立即终止应用程序,则cookie将会返回.听起来好像某种cookie同步机制没有足够快地启动,但是在HTTPCookieStore文档中没有提及它.

if you continue to use the app for a period of time, the cookies stay deleted. however, if you terminate the app immediately afterwards, the cookies will come back. sounds like some kind of cookie sync mechanism isn't kicking in fast enough, but the's no mention of it in the HTTPCookieStore docs.

您如何获取cookie以(可靠地)保持删除状态?

How do you get a cookie to (reliably) stay deleted?

推荐答案

我认为没有办法做到这一点.Cookies在发送到NSHTTPCookie类之前已被缓存,删除Cookies时也会发生同样的事情.该类被告知,以在退出时删除Cookies,但如果应用程序崩溃(因为它未捕获到适当的事件)而不会崩溃,则不会.

I do not think that there is a way to do that. Cookies are cached before they are sent to the NSHTTPCookie class and the same thing happens when you delete cookies. The class is told to delete the Cookies on quit, but won't if the app crashes as it doesn't catch the appropriate event.

这篇关于如果应用终止,则删除的NSHTTPCookie返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆