Javascript clear local data
Is there a way to clear all of my application's local data with javascript?
I would like to clear:
Session Storage
Cookies
Local Stor开发者_C百科age
Application Cache (html5 spec)
Think you would have to deal with each individually as each browser would implement differently.
sessionStorage.clear
localStorage.clear
and for cookies there is already a good answer on SO
You could of course just put these into your own function.
If the application cache is server side you could have an ajax call to a http post that deletes this.
UPDATE: it is advised against clearing application cache, http://www.whatwg.org/specs/web-apps/current-work/#expiring-application-caches. What would you be storing there that you would want deleted?
精彩评论