DEV Community

Discussion on: Using Local Storage for Remembering User Visits

Collapse
 
hacker4world profile image
hacker4world

For people reading this, you can't store objects in local storage so you need to turn it to a string using JSON.stringify() then save it

Collapse
 
thexdev profile image
M. Akbar Nugroho

Explicitly, localStorage can only store a string value. So, if you want to store an Object then you need to serialize it using JSON.stringify() and deserialize it using JSON.parse() in order to use the Object.

Collapse
 
riapacheco profile image
Ria Pacheco

Hexcellent.