sessionStorage is a special object within JavaScript that allows you to store variables inside of the users browser in a way that allows them to persist across pages. However, unlike localStorage, the variables are not retained after the browser has been closed. This is good for only retaining data that is useful within a single session (or visit) of a website.
- sessionStorage.length: a property that displays the number of variables being stored.
- sessionStorage.setItem(name, value): a method used to save a variable in a key:value pair.
- sessionStorage.getItem(name): a method to retrieve a saved variable by its name.
- sessionStorage.removeItem(name): a method that removes a specific variable by its name.
- sessionStorage.clear(): a method that empties all variables inside of sessionStorage.
- sessionStorage.key(i): a method that returns the name of the property at the index provided.