sessionStorage and localStorage not working in Internet Explorer 10

I stumbled over an interesting issue when testing the web storage support in Internet Explorer 10 (localStorage and sessionStorage).

Basically, when loading an HTML document from the local drive without using a web server (file:// protocol), these features are not working in Internet Explorer 10.

When you run the following code in Internet Explorer 10:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Web storage test</title>
</head>
<body>
    <script type="text/javascript">
        if (window.sessionStorage) {
            alert("We have session storage!");
        }

        if (window.localStorage) {
            alert("We have local storage!");
        }
    </script>
</body>
</html>

It will display the alerts only when running from a web server (local or remote) using the http(s):// protocol. When trying to open the file locally without a server, window.localStorage and window.sessionStorage will be unavailable and the alerts will not show.

If you are looking for alternatives, take a look at this stackoverflow post which lists a handfull:
HTML5 Local Storage fallback solutions

Hope this helps someone stumbling upon this issue.

A quick test with current versions of Firefox and Chrome, showed that these browsers do not share this problem.

Advertisement

Tags: , , ,

2 Responses to “sessionStorage and localStorage not working in Internet Explorer 10”

  1. none Says:

    Thank you. I stumbled on this same thing. If I run it from the LAN (one machine to another), then it works.

  2. Maria Harper Says:

    The crux of your writing whilst sounding reasonable at first, did not settle very well with me after some time. Somewhere within the paragraphs you were able to make me a believer but only for a very short while. I however have a problem with your leaps in assumptions and one would do well to help fill in all those breaks. When you can accomplish that, I could certainly be amazed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: