How can i use the localStorage? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How can i use the localStorage?

i don't understand yet, i read many articles about it but i didn't help.

22nd Apr 2018, 5:02 PM
Arthur Abreu
Arthur Abreu - avatar
2 Answers
+ 15
What is HTML Web Storage? With web 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. Web 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. Web storage is per origin (per domain and protocol). All pages, from one origin, can store and access the same data. The localStorage Object The localStorage object stores the data with no expiration date. The data will not be deleted when the browser is closed, and will be available the next day, week, or year. example: // Store localStorage.setItem("lastname", "Smith"); // Retrieve document.getElementById("result").innerHTML = localStorage.getItem("lastname"); SOURCE: https://www.w3schools.com/html/html5_webstorage.asp
22nd Apr 2018, 5:20 PM
Baraa AB
Baraa AB - avatar
+ 5
tanks for the asnwer :)
22nd Apr 2018, 8:27 PM
Arthur Abreu
Arthur Abreu - avatar