Are there any alternatives for localstorage as we are using this to store a few data. Our issue is that our app is working as an iframe in Shopify, so when testing in incognito window it denies the access of localstorage. This is the error we are getting:
Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
Can someone please suggest a solution for this issue?
CodePudding user response:
You can use these alternatives:
sessionStorage: This is similar to localStorage, but the data is only stored for the duration of the browser session. Once the user closes the browser or tab, the data is deleted.
IndexedDB: This is a browser-based, NoSQL, transactional database that can be used to store larger amounts of data. It's more complex than localStorage and sessionStorage, but it allows for more advanced data manipulation.
You can find other web databases to store data. And you can use shopify own server storage using API as well.
CodePudding user response:
If you are using chrome as browser, then it is possibly because you may be blocking third party cookies.
So in chrome's settings > Privacy and security > Cookies and other site data > set allow all cookies
When in incognito mode: Disable that option showing "Block third party cookies"