Reputation: 229
I have searched and found ways to clear cookies from a UIWebView
, but what I want to know is how to clear the cookies completely ? Guidance Needed.
Thank you.
Upvotes: 0
Views: 1353
Reputation: 1765
for(NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies])
{
if([[cookie domain] isEqualToString:@"owner.ford.com"] || [[cookie domain] isEqualToString:@"ford.com"])
{
NSLog([cookie domain]);
[[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
}
}
[[NSUserDefaults standardUserDefaults] synchronize];
Imp: Be sure to add the last NSUserDefaults line. Or the cookies would be back as you restart the app.
Upvotes: 1