A.Adams A.Adams - 4 years ago 60
Javascript Question

How to login successfully with details from local Storage [JavaScript]

So basically i store the details entered by the user in the register form into local HTML storage... And i have checked that the details ARE stored in local storage, however, when i try to log in with such information (username and password) in the login form.... it doesn't work. So how would i be able to log in the login form successfully?? In other words, how would i be able to get the data for username and password entered in the register form (which is stored in local storage) and use that to compare with user's input in login form to validate the login process?? Here are files:

Answer Source

You have to compare them to user and pass, not username and password:

var entry = localStorage.getItem("entry");
console.log("username: " + entry.user + "password: " + entry.pas);
if(username.value == entry.user && password.value == entry.pass) {
    alert('You have successfully logged in.');

}

In the browser pres CTRL + SHIFT + I, and if it's not open select "Console"

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download