admin管理员组文章数量:1315364
I am building a simple react app with a rails backend. If I give the user the option to delete his/her account, how can I simultaneously clear local storage?
Is that a back end function or can I do something on front end?
Any advice is greatly appreciated!
I am building a simple react app with a rails backend. If I give the user the option to delete his/her account, how can I simultaneously clear local storage?
Is that a back end function or can I do something on front end?
Any advice is greatly appreciated!
Share Improve this question asked Jun 22, 2017 at 4:24 peterchicpeterchic 4171 gold badge4 silver badges11 bronze badges 3- 1 Why would something that is clearly client-side storage require a "back end function" to manipulate...? – Patrick Roberts Commented Jun 22, 2017 at 4:26
- @PatrickRoberts because it'd be really useful to be able to do so :) The W3C currently have a working draft spec to do just this: w3/TR/clear-site-data – Dom Christie Commented Jun 22, 2017 at 7:51
- @DomChristie I feel violated... (kidding, but this draft honestly does seem superfluous.) – Patrick Roberts Commented Jun 22, 2017 at 7:56
2 Answers
Reset to default 7localStorage stores data into browser's or system's storage which is local to your system. So no backend process will be required. You can simply use clear() function to clear the stored data.
localStorage.clear(); //for localStorage
sessionStorage.clear(); //for sessionStorage
You can use localStorage.clear();
本文标签: javascriptHow to clear local storage when deleting userStack Overflow
版权声明:本文标题:javascript - How to clear local storage when deleting user - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741974367a2408033.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论