O'Reilly logo

Instant HTML5 Local Storage How-to by Alex Libby

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

Basic demo for Session Storage (Must know)

In this recipe, we're going to take a look at how Session Storage works, using a simple demo in the form of a click counter, which will reset each time you refresh your browser session.

Getting ready

For the purposes of this task, all you will need is a normal text editor of your choice.

How to do it...

In the following steps, we will take a look at how Session Storage works:

  1. Let's start by creating a new file. Add the following framework for our demo. Save it as sessiondemo.html:
    <!DOCTYPE html>
    <html>
      <head>
        <meta content="utf-8">
        <script src=
        "http://code.jquery.com/jquery-1.8.1.min.js"></script>
        <script type="text/javascript"></script>
      </head>
      <body>
      </body>
    </html>
  2. We need to add a button and some text. ...

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