Question

I am using the new Basecamp API for my iOS basecamp client app. I want the user to be able to logout and switch accounts. But I can't as the account credentials stored in the browser cache are used every time I request authorization. I figured out I would need to flush browser cache to do this. How do I clear the browser cache?

Was it helpful?

Solution

[[NSURLCache sharedURLCache] removeAllCachedResponses];

After that, you can deleting any associated cookies with in the UIWebView:

for(NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {

    if([[cookie domain] isEqualToString:someNSStringUrlDomain]) {

        [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top