删除本地存储数据
在使用 localStorage 编写 Web 应用程序时,用户无意或故意删除 localStorage 数据时,我会面临哪些漏洞?
我很高兴放置一个按钮,显示“删除我的数据”,这是在我的控制之下,但是是否有超出我控制范围的方法来删除 localStorage 数据?或者没有使用(即隐身模式/私人浏览模式)?
谢谢
What vulnerabilities do i face, when coding a web app utilising localStorage, of a user inadvertently or deliberately delete localStorage data?
I'm happy to put a button saying "Delete my data", this is under my control, but are there ways beyond my control that localStorage data may be deleted? Or not used (ie. Incognito mode/private browsing mode)?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
任何人都可以随时从控制台或地址栏调用
localStorage.clear()
。小书签也可以用来做同样的事情。对待
localStorage
的波动性与对待 cookie 的波动性相同。假设它随时可能消失。它最适合用于用户设置和临时数据。如果用户清除它,请准备使用默认回退或重新开始该过程。Anyone can call
localStorage.clear()
from the console or location bar at any time. It's possible for a bookmarklet to be used to do the same thing.Treat
localStorage
with the same volatility you'd treat a cookie. Assume that it can disappear at any time. It's best used for user-settings and temporary data. If a user clears it, be prepared to use default fall-backs or start the process over.localStorage是用户可编辑的,它类似于cookies。
用户可以根据需要删除/编辑它,因此您应该在服务器端进行测试...
这是愤怒的小鸟如何被黑客攻击的示例...
http://thenextweb.com/apps/2011/05/11/angry-birds-for-chrome-already-hacked-unlocking-all-levels/
localStorage is editable by the user , it's similar to the cookies .
User can delete / edit it if he wants , so you should make ur tests on server sides ...
here's an example of how angry birds got hacked ...
http://thenextweb.com/apps/2011/05/11/angry-birds-for-chrome-already-hacked-unlocking-all-levels/
以下是我们发现用户可以在 iPhone IOS4 和 iPad IOS4 上执行的操作。
杀死野生动物园
双击“操作按钮”,按住底部显示的 Safari 按钮。当中间带有 x 的圆圈出现时,单击 x。
清除 Safari 缓存
设置|野生动物园|清除缓存
启动 Safari 备份
坏消息 - 所有网站的本地存储都被清除,而不仅仅是您的!
Here's what we found a user can do on iPhone IOS4 and iPad IOS4.
Kill Safari
Double tap your "action button", press and hold the safari button that shows up on the bottom. When the circle with an x in the middle shows up, click the x.
Clear the Safari cache
Settings | Safari | Clear cache
Start Safari back up
Bad news - all sites local storage is cleared, not just yours!