If you're working with local storage, I highly recommend using the following library:
http://amplifyjs.com/api/store/
It has a very simple interface and internally it has a bunch of fall-back storage mechanisms in case one isn't supported by the browser.