'Local storage of Web BrowserAPI not working

I have used local storage to store user's password in my webpage for authentication. However, on hosting the website, the local storage has stopped working at all. How can I fix this?

localStorage.setItem('password', {{userInput }})


Solution 1:[1]

Some browsers block localStorage for Non-HTTPS sites. Check your browser's console for problem/warnings like: "localStorage blocked - not secure context".

And i thinkk there is a bug in your code. Try this:

localStorage.setItem('password', document.GetElementByID('password-input').value;)

Solution 2:[2]

 localStorage.setItem('password', JSON.stringify(userInput))

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 aWebDesigner123
Solution 2 c0dm1tu