I am using HTML5 localStorage to track my application session. Below is the my code sample.
if(typeof(Storage)!=="undefined")
{
if(sessionStorage.lastname=="Smith")
{
alert( "your Session is still active");
}
else{
sessionStorage.lastname="Smith";
alert( "Last name: " + sessionStorage.lastname);
}
}
else
{
alert( "Sorry, your browser does not support web storage...");
}
The above code works great. But when I close my IE browser from Task Manage > kill IE process, and open my application again in a new browser, then I see my old localStorage value still exist, it does not delete my localStorage of previous session.
How can I delete the localStorage, when user kills the browser from TaskManager?
When the browser is killed via the task manager, the javascript process is subsequently killed. When javascript is killed it does not fire an event that you can act on.
http://www.daniweb.com/web-development/javascript-dhtml-ajax/threads/232931/is-it-possible-detect-browser-process-termination#