Managing HTTP Cookies on iPhone

dan picture dan · Jan 13, 2010 · Viewed 59.1k times · Source

I want to port a python app that uses mechanize for the iPhone. This app needs to login to a webpage and using the site cookie to go to other pages on that site to get some data.

With my python app I was using mechanize for automatic cookie management. Is there something similar for Objective C that is portable to the iPhone?

Thanks for any help.

Answer

Steve Madsen picture Steve Madsen · Apr 20, 2010

NSURLConnection gives you cookie management for free. From the URL Loading System Programming Guide:

The URL loading system automatically sends any stored cookies appropriate for an NSURLRequest. unless the request specifies not to send cookies. Likewise, cookies returned in an NSURLResponse are accepted in accordance with the current cookie acceptance policy.