6

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?

Shyam Bhat
  • 1,600
  • 13
  • 22

1 Answers1

10
[[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];
    }
}
Romit M.
  • 898
  • 11
  • 28
  • @shyambhat, Would it only work `UIWebView` within the app or it can work for Mobile Safari too ? – Hemang Dec 29 '14 at 12:57
  • Thanks a lot Romit for your solution :) – InspiredCoder Aug 19 '15 at 22:11
  • 1
    Not works in my case. I am working on one application in which i have to fetch all emails of outlook user. After login successfully i get all emails listing. But when i try to login by different user that time it display first user data. Due to that unable to login by different user. – Protocol May 07 '19 at 11:53