O'Reilly logo

HTML5 Multimedia Development Cookbook by Lee Jordan, Dale Cruse

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Setting and getting a session storage variable

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.

Getting ready

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.

How to do it...

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>  ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required