NSHTTPCookieStorage sharedCookieStorage is empty in 10.11

NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
NSLog(@"cookieStorage count is %@", [[cookieStorage cookies] count]);


This comes up null in 10.11, works fine in 10.10.


Am I missing something obvious? Anyone else using this?

It turns out 10.11 to sandbox every individual app like iOS.

Here is my solution.


// To read cookies from Safari

NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedCookieStorageForGroupContainerIdentifier:@"Cookies"];

// To write cookies to the app

for (NSHTTPCookie *aCookies in [storage cookies]){

[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:aCookies];

}


Hope this would be helpful.

Hello,


We have tried JRWan method and it worked. We wonder if there is any official documentation that confirms that all Safari Cookies can be readed using "Cookies" group container identifier in OS X.


Can any apple developer confirm this or another user share a link ?


Thanks in advance,

Nicolas

Did you test on 10.11 or 10.12?

I just tried on 10.12 (macOS Sierra), and storage.cookies returned zero cookies, where _storage_ was initialized with the @"Cookies" group identifier.

NSHTTPCookieStorage sharedCookieStorage is empty in 10.11
 
 
Q