Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Local Storage, Session storage, Web storage, web database and cookies in HTML5

What is the difference between these concepts, and when should I use one in particular? Does this listing also contain different names for the same general concept?

  • HTML5 local storage
  • HTML5 session storage
  • HTML5 web storage
  • HTML5 web database
  • Cookies
like image 713
texai Avatar asked Mar 22 '11 22:03

texai


People also ask

What is local storage and session storage in HTML5?

localStorage - stores data with no expiration date. window. sessionStorage - stores data for one session (data is lost when the browser tab is closed)

What is local storage and session storage and cookies?

For most cases, we use the localStorage object if we want some data to be on the browser. If we want it on the server, then we use cookies, and the sessionStorage is used when we want to destroy the data whenever that specific tab gets closed or the season is closed by the user.

What are local storage functions in HTML5?

The local storage is a type of HTML5 offline storage that allows user string data to be saved synchronously in their browser. Information is kept in name and value pairs and not available between different browsers on the same device. Local storage can be used as an alternative to cookies.


1 Answers

HTML5 web storage is a generic umbrella term for the new client-side data storage options.

Local Storage is persistent and scoped to the domain. At the moment two flavors are usually mentioned:

  • 'default': stores things in name/value pairs
  • Web SQL (aka Web Database): uses an SQL database

Session Storage is non persistent and scoped only to the current window.

Cookies are the old school way of doing all of the above. Stores name/value pairs per domain.

like image 150
DA. Avatar answered Sep 19 '22 03:09

DA.