Session storage and local storage both share the web storage API. In this recipe, we will define two session storage variables, and then display them on the screen.
You will need an up-to-date browser that supports session storage. Safari and Google Chrome respond best if you are testing your files locally on your computer.
First, we will create the head area of an HTML5 page and an opening body
tag:
<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Show me the session storage</title></head><body>
Add a section
and an article
tag. Give the article tag an ID of "aboutyou".
<section><article id="aboutyou"><p></p></section>
Next, we will create two session storage variables using the setItem
method as show in the following code block:
<footer><script>sessionStorage.setItem('nickname...