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
Add a ment  | 

2 Answers 2

Reset to default 7

localStorage 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