Is Iphone NSHTTPCookieStorage available to reopen the application?

I am working on my application here, and it pretty much comes to this. I have a login window in which users are logged in, and then it saves the cookie when returning like this:

NSArray * all = [NSHTTPCookie cookiesWithResponseHeaderFields:[resp allHeaderFields] forURL:[NSURL URLWithString:@"http://myurl]]; NSHTTPCookieStorage *sharedHTTPCookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; [sharedHTTPCookieStorage setCookies:all forURL:[NSURL URLWithString:@"http://myurl"] mainDocumentURL:nil]; 

After he protects this cookie, I will take it to my home vision. My problem is that if users close prgoram, the phone restarts, etc. - are cookies stored locally on the phone sefl? I am trying to access this cookie again on didFinishLaunchingWithOptions. Now I have the following code.

  NSHTTPCookieStorage *sharedHTTPCookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; NSArray *cookies = [sharedHTTPCookieStorage cookiesForURL:[NSURL URLWithString:@"http://iphone.wazgood.com"]]; NSLog(@"count: %i", [cookies count]); 

Each time - it becomes empty in the cookie data - any ideas on whether the cookies are cleared every time the user pushes the program, or is it testing bc im on the iPhone emulator?

+1
object objective-c iphone
Jan 07 2018-11-11T00:
source share
1 answer

If you or anyone else has this problem, it may happen that the cookies expire after the session ends (when the application closes). You can check this behavior by looking at the sessionOnly property of your NSHTTPCookie (getter method -(BOOL)isSessionOnly ).

+2
Feb 14 '11 at 18:54
source



All Articles