I use UIWebView that users login in accounts. Users may login with facebook account. He is click button Facebook and opens UIWebView. After login UIWebView close and users may use your personal account. But when I close my app and open it again users not login. UIWebView not save cookies. I found this answer https://stackoverflow.com/a/26006163 And added this code in my app. This only works temporarily. I close my app and open through hours it again users not login. I tried to change this line
[cookieProperties setObject:[[NSDate date] dateByAddingTimeInterval:2629743] forKey:NSHTTPCookieExpires];
to this
[cookieProperties setObject:[[NSDate date] dateByAddingTimeInterval:100*12*30*60*60] forKey:NSHTTPCookieExpires];
But it did not help me.
Cookies are temporary and it doest miraculously come back when you relaunch the app.
you need to save the cookies or the credential in keychain and get it back once you relaunch.
I had such a problem. I tried many ways. I decided use dirty hack :D That's my way:
When I was getting NSHTTPURLResponse for facebook (or else) i save request url to NSUserDefaults:
And when I open my App i use NSURLRequest with my stored url: