Search code examples
javascriptruby-on-railsreactjshttp-redirectdestroy

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!


Solution

  • 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