jsp页面中的cookie

今天讲到cookie

添加cookie代码

Cookie cook = new Cookie("name","ccc");
  	cook.setMaxAge(24*3600);
  	response.addCookie(cook);


获取cookie代码
Cookie[] cks = request.getCookies();
    for(Cookie cook:cks){
    	if(cook.getName().equals("name")){
    	   out.println(cook.getValue());
    	}
    }

你可能感兴趣的:(cookie)