Is it possible to override Local Storage and Session Storage separately in HTML5?

后端 未结 2 432
遥遥无期
遥遥无期 2020-12-19 06:37

I know it\'s possible to override the HTML5 storage APIs by overriding Storage.prototype.getItem, setItem, removeItem and clear. But that will override those methods for bot

2条回答
  •  误落风尘
    2020-12-19 07:20

    Yes, Local Storage and Session Storage override separately in HTML5

    localStorage.setItem('name', Krishna); //here local storege value is Krishna
    sessionStorage.name = "Krishna"; //here Session storege value is Krishna
    

    In below we override Local Storage and Session Storage value separately

    localStorage.setItem('name', Sri); //here local storege value is Sri
    sessionStorage.name = "Pal"; //here Session storege value is Pal
    

提交回复
热议问题