sessionStorage over localStorage in PhoneGap

醉酒当歌 提交于 2019-12-19 14:43:25

问题


I am currently developing a PhoneGap application and am using sessionStorage rather than localStorage because we are facing some problems with localStorage.

Are there any downsides to using sessionStorage over localStorage?


回答1:


sessionStorage gets erased every time you close the application. Other than that there is no difference.

Here is the usage example:

var keyName = window.sessionStorage.key(0); //Get key name
window.sessionStorage.setItem("key", "value"); //Set item
var value = window.sessionStorage.getItem("key");// Get item
window.sessionStorage.removeItem("key"); //Remove Item 
window.sessionStorage.clear();//Clear storage


来源:https://stackoverflow.com/questions/18670731/sessionstorage-over-localstorage-in-phonegap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!