localStorage and sessionStorage

Last Updated on

For saving:

// clicks is the variable containing your value to save
localStorage.setItem('clickCounter', clicks);
// If you want to use the sessionStorage
// sessionStorage.setItem('clickCounter', clicks);

For loading:

const clicks = localStorage.getItem('clickCounter');
// If you want to use the sessionStorage
// const clicks = sessionStorage.getItem('clickCounter');

See https://stackoverflow.com/questions/58500879/implement-session-storage-in-an-angular-8-application for more examples

Lämna ett svar