只有我的应用程序的私人cookie?为什么它影响浏览器的cookie? [英] Private cookie for only my app? Why is it influencing the browser's cookie?
问题描述
当我登入我的应用程式时,同一个网站的浏览器Cookie将会遗失。为什么这个Cookie在应用程序之间共享?在Chrome中登录不会影响Safari的Cookie,我如何在我的App Store应用中模拟此行为?
When I log into my app, my browser's cookie for the same site is lost. Why is this cookie being shared between apps? Logging-in in Chrome does not affect Safari's cookies, how can I emulate that behavior in my App Store app?
我登录了网站的API并设置了Cookie : [NSHTTPCookieStorage setCookie]
I am logging into a website's API and setting a cookie via: [NSHTTPCookieStorage setCookie]
使用文档,我看到了两种获取Cookie存储位置的方法:
Using the docs, I see two ways to get the cookie storage location:
- initWithStorageLocation:
(已弃用,可在Mac OS X v10.6到Mac OS X v10.6中使用)
– initWithStorageLocation:
(Deprecated, Available in Mac OS X v10.6 through Mac OS X v10.6)
和
+ sharedHTTPCookieStorage
似乎第一个类似于我想要的,使用唯一的存储loaction,只有我的应用程序可用。但是该方法在Lion中已弃用?
It seems like the first one is similar to what I want, using a unique storage loaction that is only usable by my app. But that method is deprecated in Lion? How then do you use a private my-app-only cookie?
推荐答案
不使用操作系统的cookie管理,实现自己。 IIRC Chrome on OSX使用SQLite3数据库存储Cookie,并实现浏览器的多个部分/ http /网络通信本身。
By not using the cookie-management of the OS but implementing your own. IIRC Chrome on OSX uses an SQLite3 DB to store cookies and implements several parts of the browser/http/network communication itself.
这篇关于只有我的应用程序的私人cookie?为什么它影响浏览器的cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!