I am coding for a Firefox add-on that uses the local storage of browser to store the values of two variables. When using this is form of general HTML page i get the values of the local storage variables even after closing the browser however when i try doing the same after loading this page by an add-on I get null value for the local storage variables.
I am able to use the local variables in both the cases till I close the browser. But in case of restarting the browser the local variable value in case of add-on is lost
The script used for doing this is as follows:-
//Fetching the values in the various fields.
//Usermail and password are the ids of two input boxes
//Login is the id for an input button
var id = document.getElementById("usermail");
var pass = document.getElementById("password");
var login = document.getElementById("login");
//Saving the values for the id and password fields
login.addEventListener("click", function() {
localStorage.setItem("Email", id.value );
localStorage.setItem("Password", pass.value);
login_Email = localStorage.getItem("Email");
login_pass = localStorage.getItem("Password");
alert(login_Email); // To check the local storage values
});
The Add-on is required to store login information of the user to provide access to mail inbox and display the number of unread mails pending. This data needs to be safely stored until a delete request is initiated by the user for this data or a logout request is initiated.