Skip to content

Commit c66f26f

Browse files
committed
added session storage
1 parent acff881 commit c66f26f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

SessionStorage.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
properties and methods are similar to local storage.
3+
Session storage exists in current browser tab only.
4+
if we change the tabs, the session storage will be cleared.
5+
6+
The data survives the page refresh, but not closing/opening the tab.
7+
8+
STORAGE EVENT
9+
When the data is updated in local or session storage, storage event must be triggered with the following properties:
10+
1- key
11+
2- old value
12+
3- new value
13+
4- url
14+
5- storageArea
15+
*/
16+
17+
// sessionStorage.getItem("name")
18+
// sessionStorage.clear()
19+
// sessionStorage.removeItem("name")
20+
// sessionStorage.setItem("name", "harry")
21+
// sessionStorage.removeItem("name")
22+
23+
24+
window.onstorage = (e) => {
25+
alert("changed")
26+
console.log(e)
27+
}
28+

0 commit comments

Comments
 (0)