【发布时间】:2019-02-15 17:54:29
【问题描述】:
在应用程序中,我们将UserName 值传递给内部API。
在对API 进行Ajax 调用之前,我正在调用一个名为GetUserName() 的函数,如下所示。此函数基本上将用户名存储在cookie 中。我不想总是通过Ajax 调用服务器来获取用户名。
代码:
function GetUserName()
{
//TODO
1. If UserName Cookie exist, return it.
2. If UserName Cookie doesn't exist, then make Ajax call to server to Get
UserName and set the Cookie.
}
正如here 所说,在客户端存储用户名和密码是不好的做法。
但是想知道在这种情况下仅将用户名存储在 cookie 中是不好的做法吗?或者我应该加密 UserName 吗?
任何帮助都会很棒。
【问题讨论】:
-
由于用户名(通常)是公开信息,我看不出有任何反对的理由
标签: javascript security cookies credentials persistent-storage