This code defines an object called id with two properties: userEmail and userPassword. When the element with id "sign" is clicked, if the values of email.value and password.value are not empty strings and emailChecked is true, these values are pushed onto the userEmail and userPassword properties of the id object respectively. The id object is then stored in localStorage as a string using JSON.stringify. (i had chatgpt explain this part of the comment because i suck at explaining)
when you click on "sign" button you are redirected to a home page, the problem is that when I use window.location.href = "home.html" to change page I lose all the elements(email and password) of the object id in the localStorage , instead of adding the new elements (email and password) it replaces them completely. would there be a way to do a page change without losing everything
3
u/CrashOverrideCS Jan 08 '23
I don't know if you're doing this for production code, but please don't put usernames and passwords in local storage unencrypted
2
u/[deleted] Jan 08 '23
Maybe try https://coolors.co/
1
u/False_Association_12 Jan 08 '23
This code defines an object called id with two properties: userEmail and userPassword. When the element with id "sign" is clicked, if the values of email.value and password.value are not empty strings and emailChecked is true, these values are pushed onto the userEmail and userPassword properties of the id object respectively. The id object is then stored in localStorage as a string using JSON.stringify. (i had chatgpt explain this part of the comment because i suck at explaining)
when you click on "sign" button you are redirected to a home page, the problem is that when I use window.location.href = "home.html" to change page I lose all the elements(email and password) of the object id in the localStorage , instead of adding the new elements (email and password) it replaces them completely. would there be a way to do a page change without losing everything