//如果需要记住密码,则往外写cookie
if ("true".equals(isRemPwd)){
Cookie c1 = new Cookie("username",username);
c1.setMaxAge(10*24*60*60);
response.addCookie(c1);
Cookie c2 = new Cookie("pwd",password);
c2.setMaxAge(10*24*60*60);
response.addCookie(c2);
}else{
//把没有过期的cookie删除
Cookie c1 = new Cookie("username","1");
c1.setMaxAge(0);
response.addCookie(c1);
Cookie c2 = new Cookie("pwd","1");
c2.setMaxAge(0);
response.addCookie(c2);
}
如果前端需要记住密码的话
$.cookie("username",username,{expires:7});
$.cookie("password",password,{expires:7});
$.cookie("avatar",data.data.avatar,{expires:7});