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

Adding objects, arrays, and TTL support to storage (Become an expert)

At the very start of this book, I mentioned the need to use strings to store content in Local Storage. What if I said that it was possible to store objects and arrays in Local Storage as well? You'd be right in pointing out that these are not strings. You can still store content from data objects and arrays, if you use the power of JSON to convert them, as we will see in this recipe.

Getting ready

For this recipe, we will need our usual text editor, as well as the code that accompanies this book. We will also need a copy of the jStorage plugin that is available from http://github.com/andris9/jStorage/raw/master/jstorage.js, as well as jQuery; you can download this from http://code.jquery.com/jquery-1.8.3.min.js ...

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