1

According to Apple documentation on NSHTTPCookieStorage

The NSHTTPCookieStorage class provides the interface for managing the collection of NSHTTPCookie objects shared by all applications.

Therefore, If I'm not mistaken, since a Webview on OS X uses NSHTTPCookieStorage, and Safari uses Webviews, if I login on a given website on a Webview, Safari will use the cookies that has been set by the Webview and when the same website is opened by Safari, it should be authenticated.

My question is, if cookies are shared between Safari and Webviews. If so, why the test above is not working ?

4

3 回答 3

6

根据 NSHTTPCookieStorage 文档:

从 OS X 10.11 开始,每个应用程序都有自己的 sharedHTTPCookieStorage 单例,不会与其他应用程序共享。

因此,虽然之前的答案在 3 年前编写时是正确的,但现在的答案应该是:

1) 在 OS X 10.11 之前 - 是的,它们是共享的

2) OS X 10.11 和 macOS 10.12 - 不,它们不再共享。

于 2016-12-02T01:31:10.267 回答
5

根据了解 iPhone 的 NSHTTPCookieStorage 中的讨论,cookie 不会在应用程序之间共享。

这在“Cookie 存储”部分下的文档中得到确认:

iOS 注意:iOS中的应用程序不共享 Cookie。

于 2012-11-14T17:08:15.783 回答
1

根据我的经验,在 OS X 上,答案是肯定的。Cookie 似乎在 Safari 和 WebView 之间共享。

于 2013-06-28T14:38:44.900 回答