0
votes

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

1

1 Answers

0
votes

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