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();