aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes HTML5 localStorage  delete problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "HTML5 localStorage  delete problem" Watch "HTML5 localStorage  delete problem" New topic
Author

HTML5 localStorage delete problem

accnit Jai
Ranch Hand

Joined: Feb 15, 2011
Posts: 33
I am using browser IE8 to test my application and using the localStorage to track the application session. When I kill my browser from 'Task Manager' > 'kill IE process'. It does not clear my localStorage and when i open new browser then its says, you already have set the localStorage value.

here is the code which i am using.


How can I delete the localStorage, when user kills the browser from TaskManager?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Localstorage lives until the appliation or the user deletes the values. If you want to live for the life of the session, than you should be using sessionstorage.

https://developer.mozilla.org/en-US/docs/DOM/Storage#sessionStorage


accnit Jai
Ranch Hand

Joined: Feb 15, 2011
Posts: 33
Thanks Eric, I can not go with sessionstorage because IE8 has feature of 'New Session' and if i use the sessionstorage then i'll not be able to share the webstorage value across session. while with localstorage we have ability to share the webstorage value across the all the session of IE browser.

you said, " Localstorage lives until the application" , but in my case if i kill my browser from Task Manager then it does not clear the localstorage value. I tried to put the javascript event "onunload ="localStorage.clear();". but this get calls only when i close the browser from close button or exit. but not in the case of kill browser from TaskManger.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Killing the browser with the task manager or a browser being closed do to a run time error or computer going to sleep or whatever will not fire an unload event. There is no way to make the browser fire that event in a bunch of different scenarios.

Basically you are going to have to write some sort of hand shake between the server and the client to see if when a session starts on the server, it wipes out the session on the client.

Eric
Alok Agrawal
Greenhorn

Joined: Feb 01, 2008
Posts: 12

The local storage mechanism spans multiple windows and persists beyond the current session. Means, the data in a local storage area never expire, until we deletes through program.

Like cookies, this data persists even after you navigate away from the web site, close your browser tab, exit your browser, or what have you. Unlike cookies, this data is never transmitted to the remote web server (unless you go out of your way to send it manually). Unlike all previous attempts at providing persistent local storage, it is implemented natively in web browsers, so it is available even when third-party browser plugins are not.


Alok Agrawal
Learn Thru PPT Sports Info
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Alok Agrawal,

The poster knows this already. The poster is asking how to delete the data when the browser is exited in a way that the unload event does not fire.

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTML5 localStorage delete problem
 
Similar Threads
Problem with IE7
need to manage sigle session for same user in differnt browser
How to handle screen orientation changes
preventing a JSP bean instance from being shared by multiple users
Siteminder session timeout - AJAX response issue