My question is about fine tuning of Chrome or Chromium browser. It have support of new generation of cookies: HTML5 LocalStorage and Databases. Some ad sites uses LocalStorage to do user tracking, some other sites uses this too. Also, chrome plugins (extensions) often uses localstorage to keep settings.

I want to disable LocalStorage&DB for all sites completely or get it in "ask user" mode. But I want to use extensions which uses LocalStorage and DB.

Is it possible?

  • No. – Sathya Jun 18 '11 at 15:24
  • I have been manually deleting content in the local storage and DB folders for a while now, I leave the extension settings, but delete the rest twice a day. – Moab Jun 18 '11 at 17:37
  • 2
    There is a command-line option --disable-localstorage which works but disables localstorage for extensions. – osgx Jun 19 '11 at 9:14
  • @osgx --disable-local-storage peter.sh/experiments/chromium-command-line-switches/…, yet for some reason using this flag breaks some chrome extensions like adblock plus. – king_julien Dec 31 '13 at 8:33
up vote 22 down vote accepted

Chrome provides the ability to block HTML5 LocalStorage as part of its cookie-blocking functionality. Since both technologies ultimately allow websites to store and retrieve data on end-user devices it makes sense to manage them in the same way.

Just click the Menu icon and choose Options (or Preferences on UNIX-like platforms), click Show advanced settings..., select Content Settings, and choose the Block any sites from setting data option:

chrome cookie settings

While you're there, you can select Manage Exceptions to whitelist certain sites, or All Cookies and Site Data to manage or delete existing data.

Now when you visit a site, a small icon will appear indicating cookies or LocalStorage has been blocked: cookie blocked icon screenshot

If you click on that, choose Show cookies and other site data, and select the Blocked tab, you can see what data the site tried to save and whitelist sites on a temporary or permanent basis.

blocked cookies display

The Chrome authors are not big fans of fiddly knobs, so they're unlikely to add ones to disable individual storage methods. On the flip side, you can be reasonably sure any future storage methods will be blocked by the same mechanism without hunting for more checkboxes.

  • 6
    Blocking all cookies is a bit overkill for me. – osgx Jun 19 '11 at 9:15
  • I believe local storage and cookies are a little different things - stackoverflow.com/questions/3220660/local-storage-vs-cookies – dav Jun 28 '15 at 15:58
  • While there are technical differences between cookies and LocalStorage that matter to web authors and perhaps enthusiasts, from an end-user privacy PoV they are the same: they both let websites store and retrieve data on your device. Casual users who care about their privacy have heard all about cookies, and they care about LocalStorage for the same reasons even if they don't know what it is. If you want to block cookies, you want to block LocalStorage. If you just want those newfangled cookies to get off your lawn, the Chrome authors are unlikely to add an option for you. – Patches Jun 1 '17 at 17:30

The answer above blocks cookies as well. I came up with a makeshift solution (for Windows users, but it should work for Linux in a similar way) to block local storage and allow cookies at the same time:

Open the local storage folder:

%LocalAppData%\Google\Chrome\User Data\Default\Local Storage

The "chrome-" prefixed files are used by Chrome and extensions, do not delete them. The "http-" prefixed files is what we're after. These files are created by websites to store settings or track your browsing.

In the first step, we are going to "whitelist" local storage data for sites we trust. Select all the files you want to keep, such as http_english.stackexchange.com_0.localstorage, right-click and open their properties, then set their file attributes to "hidden". You'll see why in the next step.

Now create a batch file / shell script that will delete all non-whitelisted local storage data:

del "%LocalAppData%\Google\Chrome\User Data\Default\Local Storage\http*"

Save this as "deletelocalstorage.cmd" and double-click to run. This will delete all local storage data except the ones you whitelisted before, this simply works because hidden files are ignored by the del command.

You could execute this shell script every time before you start Chrome. An even better solution is to execute the script automatically using the Windows task scheduler, for example once a day. This will regularly clean up local storage and keep websites from tracking you, while still allowing your whitelisted sites to work.

This solution is not perfect because it does not disable local storage completely, however, this is necessary because a lot of sites will not work if local storage is outright blocked. For example, you will not be able to login on some sites or you just get a blank page.

Another solution is the brute force approach: Simply block local storage through file permissions.

  • Right click the Local Storage folder -> Properties -> Security Tab -> Advanced
  • Select your username, click Edit, and in the permissions deny "creation of new files"
  • Test it by creating a new text file in the local storage folder. It should say permission denied.

Again, keep in mind that with this approach, you'll run into problems sooner or later because some sites require local storage to work properly.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.