I am trying to build an app that has UIWebView. When I exit out of my app, I want all data to reset, including cache and cookies.

I am currently able to delete cookies (and probably cache), but the issue is that even after this deletion, some websites seem to have the data from previous activities.

This is the code I used to clear cookies and cache:

// Loops through each of the cookies and deletes them.
for cookie in NSHTTPCookieStorage.sharedHTTPCookieStorage().cookies! {

// Removes cache for all responses

This seems to work for the most websites, but even after deleting cookies and removing all cache, Google does NOT stop displaying my search history. I am NOT logged in on Google.

I would appreciate any help greatly!

Example Screenshot: Google Search History

Can you plz check ToddH answer from the following link,, it my help you stackoverflow.com/questions/5468553/clearing-uiwebview-cacheaBilal17
@aBilal17 I have tried that already, it does not work either. Thanks though!NerdyGeek

1 Answers


I have finally (after trying to figure it for two days) found a solution to this issue. I had to clear up the local storage using JavaScript within the UIWebView.


I am posting this hoping that someone will not have to spend two days just trying to figure this out!