0

I have a cookie stored up manually NSHTTPCookieStorage and whenever I want to read the cookie value I iterate all the cookies from Cookiestorage and find my cookie and read it.

NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage]; 

for(NSHTTPCookie *cookie in [cookieJar cookies]{
  if([cookie.name isEqualToString:@"mycookie"] && [cookie.domain isEqualToString:@"mydomain.com"]{
   return cookie.value;
 } 
}
return nil;

the problem is sometime I am not able to read my cookie value. will the cookie get removed automatically from sharedHTTPCookieStorage when the cookie expires

Please clarify

Dan Ram
  • 171
  • 1
  • 14

1 Answers1

0

The session cookie will get discarded regardless of expiry date when the session ends.

Please find the reference here

As far as I understand , non session cookie won't get discarded automatically and it has to be removed manually.

Please find the reference here

Durai Amuthan.H
  • 31,670
  • 10
  • 160
  • 241