HTML5 Local storage vs. Session storage

后端 未结 10 2244
甜味超标
甜味超标 2020-11-22 03:16

Apart from being non persistent and scoped only to the current window, are there any benefits (performance, data access, etc) to Session Storage over Local Storage?

10条回答
  •  遥遥无期
    2020-11-22 04:00

    Local storage: It keeps store the user information data without expiration date this data will not be deleted when user closed the browser windows it will be available for day, week, month and year.

    //Set the value in a local storage object
    localStorage.setItem('name', myName);
    
    //Get the value from storage object
    localStorage.getItem('name');
    
    //Delete the value from local storage object
    localStorage.removeItem(name);//Delete specifice obeject from local storege
    localStorage.clear();//Delete all from local storege
    

    Session Storage: It is same like local storage date except it will delete all windows when browser windows closed by a web user.

    //set the value to a object in session storege
    sessionStorage.myNameInSession = "Krishna";
    

    Read More Click

提交回复
热议问题