简体   繁体   中英

How to clear local storage when deleting user

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!

您可以使用localStorage.clear();

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM