1

When using a web view and closing the app then opening it backup, do cookies persist? (For example to keep a logged in state)

Is this possible?

Chris Muench
  • 17,444
  • 70
  • 209
  • 362
  • Checkout this link: http://stackoverflow.com/questions/5837702/nshttpcookiestorage-state-not-saved-on-app-exit-any-definitive-knowledge-docume/15633164#15633164 – Kuldeep Singh Mar 26 '13 at 09:23

3 Answers3

0

No, the cookies won't persist.

Here's a solution i hacked together today: https://gist.github.com/maciekish/6268142

Please note that the initial NSURLRequest you pass the UIWebView won't have the cookies unless you set hem.

Maciej Swic
  • 11,139
  • 8
  • 52
  • 68
  • @AndersR.Bystrup Litte fast moderation there perhaps? He asked if cookies will persist when the app is restarted. The answer is no. How is that not an answer to the question? – Maciej Swic Aug 19 '13 at 10:56
0

Can't tell you why, but my UIWebView persists cookies and session by default, even when I force-close my app. So not really sure about the previous statements.

cprcrack
  • 17,118
  • 7
  • 88
  • 91
-4

The cookies works just like mobile browser. But the only limitation is the cookie is NOT shared with browser, and different webviews has separated cookies storage.

larry
  • 53
  • 1
  • 3
  • 1
    This is not correct. Cookies in a UIWebView will not persist between app runs. – Maciej Swic Aug 19 '13 at 11:18
  • the lifetime of cookies will be defined by the web server. it could be session based which expires after webview is closed or one hour/one month which persists. – larry Feb 26 '16 at 02:50