Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is window.localStorage

The option.js file of "Email this page" (Chrome extension example) contains the following code:

if (window.localStorage == null) {
  ...
if (window.localStorage.customMailtoUrl == null) {

What does this mean? What is window.localStorage?

like image 761
Siddhpura Amit Avatar asked Apr 08 '12 01:04

Siddhpura Amit


2 Answers

localStorage/sessionStorage is part of HTML5 API. Essentially, this is what cookies are used for. But this is a lot better.

https://developer.mozilla.org/en/DOM/Storage

like image 99
Aaron Avatar answered Sep 22 '22 16:09

Aaron


From http://www.w3schools.com/html/html5_webstorage.asp:

"What is HTML Local Storage?

With local storage, web applications can store data locally within the user's browser.

Before HTML5, application data had to be stored in cookies, included in every server request. Local storage is more secure, and large amounts of data can be stored locally, without affecting website performance.

Unlike cookies, the storage limit is far larger (at least 5MB) and information is never transferred to the server.

Local storage is per domain. All pages, from one domain, can store and access the same data."

like image 30
Manuel Alves Avatar answered Sep 21 '22 16:09

Manuel Alves