0

The standard

localStorage.var = var;

Isn't working for me, for example:

localStorage.library_science1.owned = library_science1.owned;

Where library_science1 is a previously created Object with the 'owned' property. Can anyone please help?

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
AlwaysNeedingHelp
  • 1,851
  • 3
  • 21
  • 29
  • 1
    Keep in mind that `localStorage` only stores strings. Please see [Storing Objects in HTML5 localStorage](http://stackoverflow.com/q/2010892/218196). – Felix Kling Feb 18 '14 at 03:31

1 Answers1

0

Local storage only handles Strings. Use JSON.stringify(library_science1) before you store, and JSON.parse(localStorage.library_science1) when you read from localStorage.

user949300
  • 15,364
  • 7
  • 35
  • 66