JavaScript Cookies vs Session vs Storage Local
// Cookies
// Capacity: 4KB
// Accessible: any window
// Expiry: manually set
document.cookie = "name=Jet" + new Date(2021, 11, 31).toUTCString(); // expires Dec 31 2021
console.log(document.cookie); // result name=Jet
// Session
// Capacity: 5MB
// Accessible: same tab
// Expiry: on tab close
sessionStorage.setItem("name", "Jet");
console.log(sessionStorage.getItem("name")); // result Jet
sessionStorage.removeItem("name");
// Local Storage
// Capacity: 10MB
// Accessible: any window
// Expiry: never
localStorage.setItem("name", "Jet");
console.log(localStorage.getItem("name")); // result Jet
localStorage.removeItem("name");
Syntax Error