How created signup and sign in page in angular 12 using local storage with authentication?

994 Views Asked by At

I used local storage to save signup data and now I want to use that data for login page and want to authenticate user while logging whether the person is signup or not.what code should I use in login page .

1

There are 1 best solutions below

0
Runesh On

It is always better to use a Backend service for logging in. In case if you're just trying to learn.

You can save your data using local or session storage

localStorage.setItem(‘name’,’MyName’);
sessionStorage.setItem(‘nameS’,’MyName’);

and retrieve the data back in your OnInit method and use to perform any logic.

let name = localStorage.getItem(‘name’);
let names = sessionStorage.getItem(‘nameS’);

You can also use cookies but the storage size is very less 4kb and for others its 5mb