'Localstorage does not work on local webpage: security error
When using my webpage (http://localhost/mypage.html) accessing localStorage issues a security error:
Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
It is just a simple line
res = localStorage.getItem(name);
and even
console.log(localStorage);
issues the same error.
But it is a LOCAL site, so no cross domains are used.
What goes wrong here ?
Solution 1:[1]
This problem is related to a Chromium bug which is now fixed. See https://community.brave.com/t/html5-localstorage/100843
You can check if your current version is affected with this JSFiddle : https://jsfiddle.net/6sm54/2/
function lsTest(){
var test = 'test';
try {
localStorage.setItem(test, test);
localStorage.removeItem(test);
return true;
} catch(e) {
return false;
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ortomala Lokni |
