【发布时间】:2021-11-30 06:23:19
【问题描述】:
首先 - 我知道不要以这种方式保存密码和登录信息。我只是将此作为一项任务。
所以,我需要从注册表中保存用户名和密码,然后在登录表单中使用它。 我如何仅使用 html 和 JS 来做到这一点?
现在我有类似的东西:
let user_name = document.getElementById("username");
let user_paswrd = document.getElementById("password");
let store_data = () => {
let input_username = localStorage.setItem("username", user_name.value);
let input_password = localStorage.setItem("password", user_paswrd.value);
};
https://jsfiddle.net/gcu78z20/
它在本地存储中保存用户名和密码,但我需要保存所有注册的用户名和密码。然后在登录菜单中登录时将其取回。我该怎么做?用 localstore 还是 cookie 比较好?
重要信息 此表格只会在本地打开。该网站不会在网络上。
【问题讨论】:
-
@Spectric 问题是“我知道不能那样保存密码和登录信息。我只是将其作为一项任务。”
标签: javascript html forms cookies local-storage