了解iOS Cookie接受政策 [英] Understanding iOS Cookie Accept Policy

查看:396
本文介绍了了解iOS Cookie接受政策的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于NSHTTPCookieStorage的cookie接受政策的Apple文档令人困惑。

The Apple docs about the cookie accept policy for NSHTTPCookieStorage are confusing.

这就是文档所说的:


NSHTTPCookieStorage实现管理cookie存储的单例对象(共享实例)。每个cookie由NSHTTPCookie类的实例表示。通常,cookie在所有应用程序之间共享,并跨进程边界保持同步。会话cookie(cookie对象的isSessionOnly方法返回YES)是单个进程的本地进程,不会被共享。

NSHTTPCookieStorage implements a singleton object (shared instance) that manages storage of cookies. Each cookie is represented by an instance of the NSHTTPCookie class. As a rule, cookies are shared among all applications and are kept in sync across process boundaries. Session cookies (where the cookie object’s isSessionOnly method returns YES) are local to a single process and are not shared.

iOS注意: Cookie是不在iOS中的应用程序之间共享。

iOS Note: Cookies are not shared among applications in iOS.

注意:对Cookie接受政策所做的更改会影响使用Cookie存储的所有当前正在运行的应用程序。

Note: Changes made to the cookie accept policy affect all currently running applications using the cookie storage.

以下关于 - (void)setCookieAcceptPolicy:(NSHTTPCookieAcceptPolicy)aPolicy

And the following about - (void)setCookieAcceptPolicy:(NSHTTPCookieAcceptPolicy)aPolicy


默认的cookie接受策略是NSHTTPCookieAcceptPolicyAlways。更改cookie策略会影响使用cookie存储的所有当前正在运行的应用程序。

The default cookie accept policy is NSHTTPCookieAcceptPolicyAlways. Changing the cookie policy affects all currently running applications using the cookie storage.

现在我的第一个想法是应用程序是否要调用setCookieAcceptPolicy,更改将影响其他正在运行的应用程序这似乎不是这种情况。调用setCookieAcceptPolicy只会影响调用它的应用程序。

Now my first thought was if an app was to call setCookieAcceptPolicy, the change would affect other running applications. This does not appear to be the case. Calling setCookieAcceptPolicy will only affect the app which called it.

适用于所有正在运行的应用程序的唯一cookie策略是Safari。在应用程序调用setCookieAcceptPolicy之前的iOS 7中,它使用了safari策略。因此,如果将safari cookie策略设置为始终阻止,则任何应用程序在设置自己的cookie策略之前将无法使用cookie。自从iOS 7问世以来,我知道这给许多应用程序带来了问题。

The only cookie policy which applies to all running applications is the Safari one. In iOS 7 before an app calls setCookieAcceptPolicy, it uses the safari policy. So if the safari cookie policy is set to always block, then any app won't be able to use cookies until it sets its own cookie policy. I understand this has caused issues for a lot of apps since iOS 7 came out.

我的观察是否正确,或者我错过了什么?

Is my observation correct about all this, or have I missed something?

编辑

我已经向Apple提出了一个错误,等待现在回复他们。

I've raised a bug with Apple and waiting to hear back from them now.

推荐答案

我在我的应用程序上运行了一些测试,发现在iOS 7上,应用程序的默认cookie策略已设置到Safari的cookie政策。更改Safari中的cookie策略,查杀,然后重新启动我的应用程序,也会更改我的应用程序中的cookie策略。将以下行添加到我的每个应用中:

I've run some tests on my app and found that on iOS 7, the default cookie policy for apps is set to Safari's cookie policy. Changing the cookie policy in Safari, killing, and then restarting my apps, also would change the cookie policy in my apps. Adding the following line to my each of my apps:

[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];

会相应更改我的应用程序,但对Safari没有任何影响。此外,更改一个应用程序似乎不会影响我的任何其他应用程序。

Would change my apps accordingly, but not have any effect on Safari. Also, changing one app did not seem to affect any other of my apps.

这篇关于了解iOS Cookie接受政策的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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