Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript cookies vs session vs local storage

// 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");
Comment

PREVIOUS NEXT
Code Example
Javascript :: get index of first number in string javascript 
Javascript :: express-session install 
Javascript :: setinterval() nodejs 
Javascript :: captalize first letter javascript 
Javascript :: math from string js 
Javascript :: axios error network error 
Javascript :: send audio with socket io node js 
Javascript :: how to upload file with button react 
Javascript :: shuffle array in javascript 
Javascript :: scroll up btn 
Javascript :: html show password 
Javascript :: create a promise in javascript 
Javascript :: angular date pipi locale 
Javascript :: react routes multiple compoenents 
Javascript :: add two float numbers in javascript 
Javascript :: aos animation 
Javascript :: deep copy javascript 
Javascript :: How to Use the replace() String Method in javascript 
Javascript :: alternative way to handle React routes in a separate file 
Javascript :: How can i change Header Bar height in react native 
Javascript :: best javascript books 
Javascript :: bresenham algorithm 
Javascript :: bind in javascript 
Javascript :: js contenteditable button spacebar 
Javascript :: spray scala JSON formatter override def read examples 
Javascript :: how javascript interpreter works 
Javascript :: claim faucets 
Javascript :: vadd vue router 
Javascript :: recaptcha v3 
Javascript :: change profile photo with javascript 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =