Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

ความแตกต่างระหว่าง Session Storage และ Local Storage ใน HTML5

Session Storage

Session Storage ออกแบบสำหรับสถานการณ์ที่ผู้ใช้ทำ transaction เดียว แต่อาจทำ multiple transactions ใน windows ต่างๆ พร้อมกัน

Local Storage

Local Storage ออกแบบสำหรับ storage ที่ครอบคลุม multiple windows และอยู่เกิน session ปัจจุบัน โดยเฉพาะ web apps อาจต้องการเก็บ megabytes ของ user data เช่น documents ทั้งหมด หรือ mailbox บน client side เพื่อ performance

HTML5 introduce localStorage attribute ใช้ access local storage area ของหน้าเว็บ ไม่มี time limit และ local storage จะพร้อมใช้เมื่อคุณใช้หน้านั้น