Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 sandboxed 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?

like image 844
psychotik Avatar asked Mar 26 '10 00:03

psychotik


People also ask

Where are cookies stored iPhone apps?

To check where are the app cookies stored on iPhone, On an iPhone, go to Settings -> Safari -> Advanced -> Website Data and you will see all cookies stored on your device. For iOS Application using web view The UIWebView will automatically store the cookies in the sharedHTTPCookieStorage.

How do I turn cookies on my iPhone?

SAFARI for iOS (iPhone and iPad)Step 1: Go to Settings, then scroll down and select “Safari”. Step 2: Scroll down to “Privacy & Security”. Step 3: Verify “Block All Cookies” is ticked (green/white), click to allow cookies. Step 4: Clear the browser cache and reopen the browser.

What is Httpcookiestorage?

A container that manages the storage of cookies. iOS 2.0+ iPadOS 2.0+ macOS 10.2+ Mac Catalyst 13.1+ tvOS 9.0+ watchOS 2.0+

What is WKWebView?

A WKWebView object is a platform-native view that you use to incorporate web content seamlessly into your app's UI. A web view supports a full web-browsing experience, and presents HTML, CSS, and JavaScript content alongside your app's native views.


2 Answers

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

like image 196
Alex Reynolds Avatar answered Sep 19 '22 13:09

Alex Reynolds


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.

like image 31
user347383 Avatar answered Sep 20 '22 13:09

user347383