开发者

Understanding NSHTTPCookieStorage for the iPhone

Maybe I'm missing something, but from Apple's documentation for NSHTTPCookieStorage, I can't help but wonder how this is safe to use.

Does this mean that cookie storage is shared across all apps on the iPhone? If my app makes an Http call that results in some cookies being saved, do all apps now have access to these cookies?

Methods like:

cookiesForURL: Returns all the receiver's cookies that will be sent to a specified URL.

make it look even more suspicious.

Can someone explain how this is OK, and what the class does?

Also, assuming my understanding is flawed and this is indeed sandbo开发者_StackOverflowxed per-app, do calls made using NSURLRequest automatically save/retrieve cookies from this store or is it the developers responsibility to set request headers before dispatching the request?


Your application only has access to cookies within its own sandbox.


From http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/URLLoadingSystem/Concepts/URLOverview.html:

iPhone OS Note: Cookies are not shared by applications in iPhone OS.


I guess you're confused by the fact that you can access cookies from other domains/urls. That's is technically true because your native app is "a browser" when you use UIWebView. If you load www.siteA.com and www.siteB.com in your UIWebView, both domain's cookies are available to your objc code. All apps, including mobile safari has it's own CookieJar and none of them can access the other one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜