What is Local Storage?
1. Local storage is client-side storage for web applications.
2. It stays there as long as it's not cleared unlike session storage, which lasts for the current browser tab session.
How will Work with Local storage:
- localStorage.setItem()
- localStorage.getItem()
- localStorage.removeItem()
- localStorage.clear()
LocalStorage.setItem
The SetItem method allows you to add a value to the local storage. It stores data using a key-value pair.
localStorage.setItem('Token_Key')
LocalStorage.getItem
The GetItem allows you to read back the data saved in local storage using the same key.
localStorage.getItem('Token_Key')
LocalStorage.removeItem
Once you are done using the data in the local storage, you can remove it using the RemoveItem method.
localStorage.removeItem('Token_Key')
LocalStorage.clear
You can Clear all of the data out of the local storage using the clear method to wipe the slate clean.