I am making a form and want to store the data that the client types in the browser cache, if the tab is closed the client does not have to type everything again.
What is the best way to meet this need?
I am making a form and want to store the data that the client types in the browser cache, if the tab is closed the client does not have to type everything again.
What is the best way to meet this need?
You can use WebStorage of an object, such as a localStorage of the fields:
Imagine that you have two input fields one with ID = name
and another ID = lastname
you can do localstorage of these fields in this way:
var lastname = document.getElementById("lastname").value;
var name = document.getElementById("name").value;
localStorage.setItem("lastname", lastname);
localStorage.setItem("name", name);
where the first part within the parentheses represents the name of the "attribute" of localStorage, and can be referenced by localStorage.lastname
/ localStorage.name
In addition to localStorage , there is also sessionStorage ( link , which turns out to be safer, since it is session-based, and complemented with an authentication system, can be time-controlled