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
  • 756,363
  • 169
  • 1,062
  • 1,111
AlwaysNeedingHelp
  • 1,659
  • 2
  • 19
  • 28
  • 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,154
  • 6
  • 33
  • 65