I need a log out button for my app, I have the below code:
while ([[[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies] count] != 0) {
for (NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {
[[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
}
}
(the while is just there to make sure they get deleted, it only runs once however)
If I NSLog the description of shared cookie storage after the above code it outputs that the array is empty. However I terminate the app or just close it, and then NSLog the description of the shared cookie storage the first thing after the app starts, all the cookies are still there.
I have tried setting Cookie
to nil in the for loop, and even tried sending dealloc to the cookies (I know you shouldn't do that but I'm now trying anything)
NSLog(@"%@", [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]);
Then executed your code. Relaunch. Cookies are gone. Strange! – Stipple