Search code examples
htmlcookieslocal-storageweb-sqlsession-storage

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

Solution

  • 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.