Should I use clear()
to obliterate everything in localStorage
, or should I just manually removeItem()
the ones I've set on that particular site (which is easy enough to keep track of)?
I ask because I don't want to end up wiping out users' localStorage
if they have other values set. I'm testing this in localhost and noticed that by using clear()
, everything I'd set previously in other projects was wiped out.
EDIT: I should have mentioned that I know localStorage is domain-locked. I'm running a site that follows this structure:
public-html
(localStorage)
--project1
----files
--project2
----files
--project3
----files
Where each file uses it's own separate localStorage variables. If I localstorage.clear()
inside project2, project1 and project3's settings will be lost as well.