Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I know this is an old question, but I have the answer here:</p> <p>It turns out that cookies aren't the only way that UIWebView stores data. There's also this persistent thing called NSURLCredentialStorage and the only way to clear it is thus:</p> <pre><code>NSLog(@"Logging out..."); // Clear credential storage NSURLCredentialStorage *credentialStorage = [NSURLCredentialStorage sharedCredentialStorage]; NSDictionary *credentialProtectionSpaces = [credentialStorage allCredentials]; for (NSURLProtectionSpace *protectionSpace in credentialProtectionSpaces) { NSDictionary *credentials = [credentialStorage credentialsForProtectionSpace:protectionSpace]; for (NSString * username in credentials) { [credentialStorage removeCredential:[credentials objectForKey:username] forProtectionSpace:protectionSpace]; NSLog(@"clearing: %@", username); } } NSLog(@"checking..."); credentialStorage = [NSURLCredentialStorage sharedCredentialStorage]; credentialProtectionSpaces = [credentialStorage allCredentials]; for (NSURLProtectionSpace *protectionSpace in credentialProtectionSpaces) { NSDictionary *credentials = [credentialStorage credentialsForProtectionSpace:protectionSpace]; for (NSString * username in credentials) { [credentialStorage removeCredential:[credentials objectForKey:username] forProtectionSpace:protectionSpace]; NSLog(@"checking: %@", username); } } </code></pre> <p>You''ll find that the usernames show the first time, but don't show when checking the second time through the same loop. They've been deleted from the NSURLProtectionSpaces.</p> <p>-Sean</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload