Struts 利用cookie保存用户的登陆信息

Cookie cookieUser = new Cookie("userId",request.getParameter("userId"));
cookieUser.setMaxAge(60*60*24*30*365);
cookieUser.setPath("/");
response.addCookie(cookieUser);

Cookie cookiePassword = new Cookie("password", request.getParameter("password"));
	        if ("1".equals(this.getContext().getParam("keepPass"))){
	            cookiePassword.setMaxAge(60 * 60 * 24 * 30 * 365);
	        }else{
	            cookiePassword.setMaxAge(0);
	        }
	        cookiePassword.setPath("/");
	        this.getResponse().addCookie(cookiePassword);

你可能感兴趣的:(java,struts)