Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A few facets to your question.</p> <p>To start with, NSURLConnection will, by default, manage cookies based on the settings for the device. It will save the cookies to the store and send them as appropriate (when the domain matches an existing cookie). This means if you make a request from a URL with a cookie saved in the cookie store, it will be sent. This explains the behavior you mentioned. Generally, with the default settings, the cookie will persist for quite a while.</p> <p>This initial statement, however, maybe is not helpful for your needs. I am assuming you may want to have control over the expiration of (or keep around "forever") this <code>secure_cookie</code> field so your app does not have to authenticate further in the future.</p> <p>In this case, <code>NSHTTPCookieStorage</code> is the place to look. This class will allow you to both retrieve: </p> <blockquote> <p>[[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:[NSURL URLWithString:@"<a href="http://example.com">http://example.com</a>"]]</p> </blockquote> <p>and set:</p> <p><code>[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie]</code> (plus setting up the cookie dictionary object)</p> <p>Based on experience and the feedback of others online, you should note that the cookie storage is not always 100% reliable. If you would like to be sending a specific cookie and value to the server, you should store that value with your app (prefs or Core Data, for example), and reset the cookie with the appropriate <code>NSHTTPCookieStorage</code> at each startup.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload