I am using browsers localStorage
to store a value, but while using google chrome, when we refresh the page using window.location.reload()
, localStorage.value
is flushed. e.g
localStorage.value1=true
after reloading, i am not getting this value1 object in localStorage.
Same code works on mozila firefox, but not in chrome. While using firefox, localstorage value is persistent.
LocalStorage supports only string values, not boolean or others.
Method to store and retrieve values:
Put the value into storage
localStorage.setItem('value1', 'true');
Retrieve the value from storage
var val1 = localStorage.getItem('value1');