chrome:为什么localStorage还包含sessionStorage数据?
我正在将 AWS Cognito 用于我的 Web 应用程序并使用 Chrome 浏览器进行测试。
我从默认的 AWS Cognito / Amplify 配置开始,以便将令牌存储在 chrome localStorage 中。当我关闭浏览器并重新打开它时,我仍然可以登录,而无需再次输入用户名和密码。
现在,我更改了 AWS Cognito / Amplify 配置,
Auth.configure({ storage: window.sessionStorage })
以便令牌应存储在 chrome sessionStorage
中,并且用户在关闭选项卡/浏览器时自动注销。
我已经确认它有效 - 我看到令牌出现在 sessionStorage 中,并且在关闭选项卡/浏览器时我确实已经注销。
但是,我仍然看到令牌出现在 localStorage 中,即使它们在 localStorage 中,它们也无法在选项卡关闭后继续存在:
正如您在 sessionStorage 中看到的,access/id/refresh 令牌是红线的:
并且在localStorage中,访问/id/刷新令牌也在那里:
但是,它们无法在选项卡关闭后继续存在。
他们为什么在那里?
I am using AWS Cognito for my web app and testing with Chrome browser.
I started with the default AWS Cognito / Amplify configurations, such that the tokens are stored in chrome localStorage. When I close browser and re-opens it, I can still login without entering username and password again.
Now I changed AWS Cognito / Amplify configurations to
Auth.configure({ storage: window.sessionStorage })
such that tokens should be stored in chrome sessionStorage
and users automatically log out when closing the tab/browser.
I have confirmed that it works - I see tokens appear in sessionStorage and I indeed have logged out when closing the tab/browser.
However, I still see tokens appear in localStorage, and even though they are in localStorage, they do not survive tab closing:
As you can see in sessionStorage, access/id/refresh tokens are red-lined:
And in localStorage, access/id/refresh tokens are also there:
However, they do not survive tab closing.
Why are they there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎忘记清除站点数据(应用程序浏览器的选项卡)
因为
Auth.configure({ storage:})
仅将其设置在适当的存储中Seems you forgot to clear site data (Application browser's tab)
Because
Auth.configure({ storage:<your_storage> })
sets it up in appropriate storage only