Out of my knowledge → you do not have to remove the key each time.
Normaly it will overwrite the old value.
But maybe something again changed in the APIs.
Why you dot not testing it on your own ?
We write data to SESSION-STORAGE:…
session.setItem('key', 'true')
We use a TIMER to get the data back out of the storage…
setTimeOut(()=>{
let storageValue = session.getItem('key');
console.log('Loaded-Value: ', storageValue );
},1500);
We do it again, setting another value for the -->same ← —> key <—
session.setItem('key', 'false');
setTimeOut(()=>{
let storageValue = session.getItem('key');
console.log('Loaded-Value: ', storageValue );
},1500);
What do you get as RESULT ???
To give the whole testing-setup a better overview, you add 2 buttons, which will simulate of setting FIRST STORAGE-VALUE and SECOND STORAGE-VALUE.
$w.onReady(()=>{
$w(#'button1').onClick(()=>{});
$w(#'button1').onClick(()=>{});
});
Completed TESTING-CODE…
$w.onReady(()=>{
$w(#'button1').onClick((e)=>{console.log(e.target.id+'-clicked');
session.setItem('key', 'true');
setTimeOut(()=>{
let storageValue = session.getItem('key');
console.log('Loaded-Value: ', storageValue );
},1500);
$w(#'button2').onClick((e)=>{console.log(e.target.id+'-clicked');
session.setItem('key', 'false');
setTimeOut(()=>{
let storageValue = session.getItem('key');
console.log('Loaded-Value: ', storageValue );
},1500);
});
});
CONCLUSION… ??? → already took a look into → CONSOLE ?