例:aa.com可以是i.aa.com,t.aa.com等二级域名,所以不要写成是:www.aa.com
public static void addCookie(String name, String value) throws UnsupportedEncodingException{
if(null != name && null != value && !"".equals(name)){value = URLEncoder.encode(value, "utf-8");
Cookie cook = new Cookie(name, value);
cook.setMaxAge(60 * 60 * 24 * 14);
cook.setDomain("aa.com");//域名cookie
cook.setPath("/");
ServletActionContext.getResponse().addCookie(cook);
}
}