The following simple code works in Firefox (12.0) but does not seem to work in IE 9 even though local storage is supported in IE9. Notice how alert(localStorage.lastname); does not show up any results. Was wondering if there is a known issue in using localStorage in IE9 as the documentation does say it is supported.
<!DOCTYPE html>
<html>
<body>
<script>
if(typeof(Storage)!=="undefined")
{
alert('local storage')
localStorage.lastname="Smith";
alert(localStorage.lastname);
}
else
{
alert("Sorry, your browser does not support web storage...")
}
</script>
</body>
</html>
Never set/get the items in localstorage directly! Use the appropriate methods for that:
This fixes your IE problem and you will live happily 😀
(Note, that the values are stores as strings!)