<body>
<%
String[] cookies=request.getParameterValues("checkbox");
if(cookies!=null&&cookies.length>0){
String username=request.getParameter("username");
String password=request.getParameter("password");
Cookie newpassword=new Cookie("username",username);
Cookie newusername=new Cookie("password",password);
newusername.setMaxAge(864000);
newpassword.setMaxAge(864000);
response.addCookie(newusername);
response.addCookie(newpassword);
}else{
Cookie[] cookiess=request.getCookies();
if(cookiess!=null&&cookiess.length>0){
//课程讲的是for(cookies c:cookiess)这句不太理解然后下面就自己想了个for出来这里哪里有错误啊。
for(int i=0;i<cookiess.length;i++){
if(cookiess[i].getName().equals("username")||cookiess[i].getName().equals("password")){
cookiess[i].setMaxAge(0);
response.addCookie(cookiess[i]);
}
}
}
}
%>
</body>
添加回答
举报
0/150
提交
取消