FYI, You Can’t Store Objects in HTML5 Web Storage

The following won’t work, because sessionStorage and localStorage will only store strings:

var myObject = { bar: 'baz' };

sessionStorage.setItem('foo', myObject);
sessionStorage.getItem('foo'); // Returns '[object Object]'

localStorage.setItem('foo', myObject);
localStorage.getItem('foo'); // Returns '[object Object]'

Solution = JSON.stringify()

The solution is to stringify your object:

var myObject = { bar: 'baz' };

sessionStorage.setItem('foo', JSON.stringify(myObject));
JSON.parse(sessionStorage.getItem('foo'));
// Returns Object {bar: "baz"}

localStorage.setItem('foo', JSON.stringify(myObject));
JSON.parse(localStorage.getItem('foo'));
// Returns Object {bar: "baz"}