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

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 .



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Runesh