google chrome - Clear HTML5 local storage on a specific page

23
2014-04
  • Anderson Green

    Is it possible to clear HTML5 local storage on a specific web page? I was editing a Javascript demo on http://jsfiddle.net, and I re-arranged the windows in such a way that one of them became impossible to resize. Is it possible to clear local storage on a specific page in this case?

  • Answers
  • Synetech

    Chrome does not yet provide an interface to manage HTML5 local-storage, so to delete local-storage in Chrome, you will need to either manually search for and delete the file in the Local Storage sub-directory in the User Data. You can find it by looking for a file that contains the domain name.

    You can also use the Delete cookies and other site and plug-in data entry in the Clear browsing data dialog (chrome://chrome/settings/clearBrowserData or Ctrl+Shift+Delete), however it does not give you fine-grained control at the site level.

    For the record, jsfiddle.net does not use local-storage for its frames, it uses standard cookies which you can delete in chrome://chrome/settings/cookies. Just type jsf in the edit box, then click the window_sizes cookie, then the [Remove] button. To delete all cookies at jsfiddle.net, just click the jsfiddle entry (not any spefcific cookie), and press Delete.

  • jmort253

    While Chrome does not provide a UI for clearing localStorage, there is an API that will either clear a specific key or the entire localStorage object on a website.

    //Clears the value of MyKey
    window.localStorage.clear("MyKey");
    
    //Clears all the local storage data
    window.localStorage.clear();
    

    Every Chrome browser, by default, has the JavaScript console installed. So an alternative method, and perhaps the easiest way, to clear localStorage is to right click on the page, click "Inspect Element", then click the "Console" tab. When the console opens, type the following JavaScript, and press enter:

    window.localStorage.clear()
    

    Once done, localStorage will be cleared. Note that this affects all web pages on a single domain, so if you clear localStorage for jsfiddle.net/index.html (assuming that's the page you're on), then it clears it for all other pages on that site. See HTML5Goodies - A Peek into Local Data Storage in HTML 5 for more information.

  • Sathya

    Chrome now provides an option to clear Local Storage of a specific site. For this, enter this in the Omnibox

    chrome://settings/cookies#cont
    

    Now, you can type the site name, select Local storage and click on Remove to clear local storage for the site

    enter image description here


  • Related Question

    privacy - How to clear all HTML5 local storage from Safari?
  • Arjan

    It seems stackauth.com has used some local storage which my Safari does not show me, and hence cannot be deleted. So, in general: how to ensure all local storage is deleted from Safari?

    Some background and details:

    The HTML5 Local Storage allows websites to store information on a computer. (That's a bit like cookies, but the contents are not sent to the server automatically.) Like when one has once logged in to the (new) Twitter website, then when viewing that site and pasting the following into the location bar shows a lot of details, even when not currently logged in:

    javascript:alert(localStorage.getItem(':USER:'));
    

    To get rid of this data: in Google Chrome "Delete cookies and other site data" does the trick. In Firefox, it's deleted whenever cookies are deleted. Not so much in Safari.

    In Safari there seems to be a related preference in Security, button "Show databases". However: that list of "Show databases" in Safari does NOT mention stackauth.com, as used by the Stack Exchange global network auto-login. And after using "Remove all", I still get results on that site:

    javascript:alert(localStorage.getItem('GlobalLogin'));
    

    I could delete this by using javascript:localStorage.clear();. But then I need to know that a site has stored data. This question is not just about StackAuth; I want to be sure other sites are not hidden from the list as well.

    (I'm on a Mac, using the latest Safari on the latest OS X.)

    When the popup is too large to see any close button, then hit Esc or Return to close the alert dialog.


  • Related Answers
  • Seasoned Advice (cooking)

    In recent versions of Safari (I am on 5.1 now), local storage can be cleared with Safari » Reset Safari » Remove all website data. Or by using Safari » Preferences » tabsheet Privacy » Cookies and other website data » Remove All Website Data. And even by using Remove All when viewing the details on that very same Privacy tabsheet. The Security tabsheet no longer shows any button to view the databases.

    Some more details, also for older versions:

    On my Mac, I found the folder ~/Library/Safari/LocalStorage, which has a file for each site that uses local storage, with its creation date set to my very first visit to each site. On Windows, this might be in a folder like %APPDATA%\Apple\Safari or %APPDATA%\Apple Computer\Safari.

    Deleting all those files, and restarting Safari, obviously cleared the data for StackAuth too.

    However, logging in to a random Stack Exchange site gets me the StackAuth data again, and a file in the above folder, without ever being prompted to allow that (my Safari preferences show "Database storage: none allowed before asking"), and without the domain being shown in the "Show databases" list. This also happens in private browsing modes.

    This seems to be caused by the difference between HTML5 Web Databases, and HTML5 Web Storage (the latter including local storage). Chrome shows both for Twitter:

    Databases and local storage in Google Chrome

    Apparently Safari only warns for databases, not for local storage? Maybe blocking local storage is going to be as hard as stopping Adobe Flash from leaving its privacy trail. The specifications state:

    User agents should expire data from the local storage areas only for security reasons or when requested to do so by the user.

    Let's hope someone knows of an easier way, or that we get some more control in future releases. (I filed a feature request at Apple for that.)

    In my case, I found as many as 5,904 items dating back to March 2009. And even my own domains, for which I'm sure no local storage is used, were listed with 8kb files each. Investigation shows that Alexey Ruzanov's FlashBlock user script uses local storage too, and hence causes a file for each site one visits, regardless whether it uses local storage, and regardless whether it uses Flash.