1

i have a iOS application that basically is a webview that contains a mobile web app, the web app requires a login, i've setter up all the scripts and everything to have the feature "remember me" when you login (a cookie is created)

but after a while of no activity (if the app is running in the background), and if you open the app again it ask you to login, even though i checked "Remember me"

Question: do i need to enable the web view to accept cookies or something?, assumed that since the UIwebview is built on iOS Safari it would just work...

Appreciate any help/clarification

Michael
  • 183
  • 3
  • 11

1 Answers1

0

iOS stores cookies in a singleton object that manages storage of cookies, see NSHTTPCookieStorage. Check to see if your cookie exist by retrieving all the cookies contained in that object.

code:

NSArray *httpCookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:aHttpUrl];
Shams Ahmed
  • 4,498
  • 4
  • 21
  • 27
  • So without adding that code even if everything is setup in my php, the web view won't automatically accept and remember the cookie? – Michael May 18 '14 at 17:40
  • that code checks for existing cookies, the webview should automatically store cookie. if it doesn't try saving cookie with [example](http://stackoverflow.com/questions/14997879/keep-losing-php-session-cookie-in-uiwebview) – Shams Ahmed May 18 '14 at 17:46