Software Archive
Read-only legacy content
17061 Discussions

Session Storage not clearing after each app restart

Robert_C_6
New Contributor I
461 Views

I have a token that I am trying to store into session storage so that it is cleared after each time the app is restarted but the toke persists even after i close and reopen the simulator.

here is my code for the storage

  sessionStorage.setItem("url", "http://robbotdev.com");

 

 

0 Kudos
1 Solution
Shahab_L_Intel
Employee
461 Views
 

I cannot reproduce this. When I close the simulator and reopen the data in sessionStorage is deleted.

To test this, I made a couple of small modifications to the blank html5 template project of the Intel XDK as follows:

In index.html

<p id="p1">Hello, Intel XDK!</p>
<button onclick="testFunction()"> Test </button>

In app.js

function testFunction() {
  var name = "none";
  if(sessionStorage.getItem("name")) {
    name = sessionStorage.getItem("name");
  }
  document.getElementById("p1").innerHTML= "Hello " + name;
  sessionStorage.setItem("name", "John");
}

The first time you click on the button it shows "Hello none", but in consequent calls it shows "Hello John". After closing and restarting the simulator, the first time it shows "Hello none" again.

View solution in original post

0 Kudos
2 Replies
Shahab_L_Intel
Employee
462 Views
 

I cannot reproduce this. When I close the simulator and reopen the data in sessionStorage is deleted.

To test this, I made a couple of small modifications to the blank html5 template project of the Intel XDK as follows:

In index.html

<p id="p1">Hello, Intel XDK!</p>
<button onclick="testFunction()"> Test </button>

In app.js

function testFunction() {
  var name = "none";
  if(sessionStorage.getItem("name")) {
    name = sessionStorage.getItem("name");
  }
  document.getElementById("p1").innerHTML= "Hello " + name;
  sessionStorage.setItem("name", "John");
}

The first time you click on the button it shows "Hello none", but in consequent calls it shows "Hello John". After closing and restarting the simulator, the first time it shows "Hello none" again.

0 Kudos
Robert_C_6
New Contributor I
461 Views

Thanks for replaying Shahab! After I restarted the program this error seems to have gone away

0 Kudos
Reply