1

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.

OshoParth
  • 1,492
  • 2
  • 20
  • 44
  • Could you provide some details, especially the scope of your addon code? – paa Aug 05 '15 at 17:18
  • Without more information in the question, it appears likely that this is a duplicate of: [Simple storage not persisting data between sessions](http://stackoverflow.com/questions/31061310/simple-storage-not-persisting-data-between-sessions) – Makyen Aug 06 '15 at 04:08
  • @paa The addon basically emphasizes storing the user information in browser storage even after consecutive restarts until the delete request is initiated by the user. – OshoParth Aug 06 '15 at 04:17
  • Are you using this localStorage from a panel file? – Noitidart Aug 08 '15 at 17:55
  • Yes I am doing it from a js file called via panel for controlling the html file landing in panel – OshoParth Aug 08 '15 at 18:03

0 Answers0