4

i am using a webview in an app which has keep me signed in functionality like facebook app.so in order to implement i need that the cookie should be persistant.I just wanted to know whether ios persists the cookie by default when the app is closed or i need to save the cookie manually before closing the app to implement keep me signed in functionality.

any help would be deeply appreciated. Thanks

dead_soldier
  • 429
  • 1
  • 5
  • 18

1 Answers1

1

You want to use a NSHTTPCookieStorage object to manage the cookies. The short answer to your question is to use NSHTPPCookieStorage which will distribute the shared instance. You can use this instance to get/set cookie information.

Take a look at the Apple documentation for NSHTTPCookieStorage, as well as the following two posts:

Where are an UIWebView's cookies stored?

http://blog.andrewpaulsimmons.com/2008/08/add-set-and-delete-cookies-in-uiwebview.html

These should get you started down the right track.

Community
  • 1
  • 1
Joey J
  • 1,355
  • 10
  • 26
  • Pretty sure that cookies will not be shared across different apps using the NSHTTPCookieStorage shared instance. – Danra Mar 17 '12 at 20:36
  • @Danra, whoops I misinterpreted the Apple doc that states, "NSHTTPCookieStorage implements a singleton object (shared instance) that manages the shared cookie storage. These cookies are shared among all applications and are kept in sync cross-process." - good call will edit answer. – Joey J Mar 17 '12 at 20:39
  • 3
    Yes and this sentence is followed by "iOS Note: Cookies are not shared among applications in iOS."... Nice documentation Apple... :) – Danra Mar 17 '12 at 21:27