4
votes

After using some code to delete all of the cookies:

NSHTTPCookie *cookie;
    NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
    for (cookie in [storage cookies]) {
        [storage deleteCookie:cookie];
    }

if you continue to use the app for a period of time, the cookies stay deleted. however, if you terminate the app immediately afterwards, the cookies will come back. sounds like some kind of cookie sync mechanism isn't kicking in fast enough, but the's no mention of it in the HTTPCookieStore docs.

How do you get a cookie to (reliably) stay deleted?

1

1 Answers

0
votes

I do not think that there is a way to do that. Cookies are cached before they are sent to the NSHTTPCookie class and the same thing happens when you delete cookies. The class is told to delete the Cookies on quit, but won't if the app crashes as it doesn't catch the appropriate event.