File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTML5 localStorage delete problem

 
accnit Jai
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
Java jQuery
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic