What is the difference between Local Storage and Session Storage in the Web Storage API?
Instruction: Describe the main differences between local storage and session storage, including their typical use cases.
Context: This question probes the candidate's understanding of client-side storage options available in modern web browsers, an important aspect of state management in web applications.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
Both APIs store string keys and values synchronously in the browser. localStorage is associated with an origin and normally survives page/browser sessions; it has no application-specified expiration. It is not durable backup: users, privacy settings and storage policies can remove or deny data.
sessionStorage is separated by origin and top-level browsing context, normally a tab. It survives reloads within the page session and ends when that session ends...
Related Questions
-
easy
-
medium
-
hard
-
hard