Can't store Chinese in cookies?

 

Chinese cannot be stored in cookies

    Yesterday, I added the username and password to the cookie during development, and then extracted it through js on the client side to realize the problem of remembering the username and password, but I encountered the following problems:

When written like this:

Cookie cookie1 = new Cookie("username","admin");

Cookie cookie2 = new Cookie("password","123456");

cookie1.setMaxAge(60);

cookie2.setMaxAge (60);

response.addCookie(cookie1);

response.addCookie(cookie2);

Doing so can achieve the function of remembering the password, but changing it like this will not work.

Cookie cookie1 = new Cookie("username","管理员");

Cookie cookie2 = new Cookie("password","123456");

cookie1.setMaxAge(60);

cookie2.setMaxAge (60);

response.addCookie(cookie1);

 

response.addCookie(cookie2);

Just changing "admin" to "administrator" cannot achieve the function of remembering the password. Why is this? The encoding is utf-8. You can see two cookies by viewing the cookie in the browser, but you cannot see the "administrator's value" corresponding to the username when you put it in Chinese. Why?

Do you have any good solutions for remembering username and password?

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326638154&siteId=291194637