Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

session storage not working in IE

I am using the following code to test session storage of HTML 5.. It is working fine in all the browser except IE. The IE version installed is 10.

Code :

<!DOCTYPE html>
<html>
<head>
<script>
function clickCounter()
{
if(typeof(Storage)!=="undefined")
  {
  if (sessionStorage.clickcount)
    {
    sessionStorage.clickcount=Number(sessionStorage.clickcount)+1;
    }
  else
    {
    sessionStorage.clickcount=1;
    }
  document.getElementById("result").innerHTML="You have clicked the button " + sessionStorage.clickcount + " time(s) in this session.";
  }
else
  {
  document.getElementById("result").innerHTML="Sorry, your browser does not support web storage...";
  }
}
</script>
</head>
<body>
<p><button onclick="clickCounter()" type="button">Click me!</button></p>
<div id="result"></div>
<p>Click the button to see the counter increase.</p>
<p>Close the browser tab (or window), and try again, and the counter is reset.</p>
</body>
</html>

What could be the problem?

like image 284
Mitaksh Gupta Avatar asked Apr 25 '13 10:04

Mitaksh Gupta


People also ask

Does IE have sessionStorage?

To check local and session storage in Internet Explorer 11 (IE11) and Microsoft Edge you must press F12 button on your keyboard, and switch tab to “CONSOLE”. Here you must write only text “sessionStorage” or “localStorage” and data would be displayed.

How do I view session storage in IE11?

In IE11, you can see local storage in console on dev tools: Show dev tools (press F12 ) Click "Console" or press Ctrl + 2. Type localStorage and press Enter.

How do I reset my session storage?

We can get specified session storage using the getItem() method. We can clear the session storage by using the clear() method.


1 Answers

What I found with both local storage and session storage features of HTML5 is that, that both these features will work in Internet Explorer ONLY when the page is rendered through HTTP, and will not work when you are trying to access these features on your local filesystem, i.e. you are trying to open the sample webpage directly from the filesystem with the URL of the sorts, C:/Users/Mitaksh/Desktop , etc..

Deploy your application over any application server like Tomcat,etc, and then access it.. and you can see both local and session storage in action then..

like image 160
Mitaksh Gupta Avatar answered Oct 14 '22 18:10

Mitaksh Gupta