Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useLocalStorageState throws errors when cookies disabled #800

Closed
arelaxend opened this issue Dec 22, 2020 · 2 comments
Closed

useLocalStorageState throws errors when cookies disabled #800

arelaxend opened this issue Dec 22, 2020 · 2 comments
Assignees
Labels
help wanted Extra attention is needed v3

Comments

@arelaxend
Copy link

Hi there,

Cookies are often disabled nowadays during browser private session. While cookies are disabled, useLocalStorageState throws SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.

Capture d’écran 2020-12-22 à 12 07 08

A.

@awmleer awmleer self-assigned this Dec 26, 2020
@awmleer awmleer added the help wanted Extra attention is needed label Jan 4, 2021
@Yunkou
Copy link
Contributor

Yunkou commented Feb 2, 2021

Technically speaking, cookies and the Web Storage API are different things, but a common user probably does not know the difference, nor need to. A common user has, however, heard about security concerns with cookies. He may also have heard advice to regularly clear cookies or disable them altogether. And so, a common user expects a function that says "Disable Cookies", but actually means "Don't let websites persist data on my computer".

I believe that is why most browsers continue to provide the familiar function of disabling "Cookies", but of course do more than that under the hood in order to fulfill what they think is the actual user intent.

For now, the behaviour is browser-dependent. Disabling cookies on each of these browsers disable the following:

Chrome: cookies, localStorage, sessionStorage, IndexedDB
Firefox: cookies, localStorage, sessionStorage
IE: cookies only
I do think that for the sake of precision and flexibility, browser vendors should tweak their implementation to have a basic option "Don't let websites store data on this computer" which disables cookies and all persistent storage mechanisms, as well as "Advanced Settings" functionality to individually disable various storage mechanisms.

see more

@brickspert
Copy link
Collaborator

Hello:

这个问题我们已经在 v3.0 版本彻底修复,目前 v3.0 版本已经发布 alpha 版本。

欢迎试用。

文档:https://ahooks-next.surge.sh/
源码:https://github.com/alibaba/hooks/tree/next

安装最新分支

$ npm install --save ahooks@next
# or
$ yarn add ahooks@next

We have fixed this problem in the v3.0 version, and the alpha has been released.

Welcome to try.

Doc:https://ahooks-next.surge.sh/
Source Code:https://github.com/alibaba/hooks/tree/next

Install v3.0

$ npm install --save ahooks@next
# or
$ yarn add ahooks@next

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed v3
Projects
None yet
Development

No branches or pull requests

4 participants