怎樣更改瀏覽器的cookie保存時(shí)間
2 回答

大話西游666
TA貢獻(xiàn)1817條經(jīng)驗(yàn) 獲得超14個(gè)贊
int maxAge = 365*24*3600;//cookie的存活期
CookieUtils.addCookie("name",value,response,maxAge,request.getContextPath());
public static void addCookie(String name, String value, HttpServletResponse response, int maxAge, String path) throws Exception {
String str = URLEncoder.encode(value, "UTF-8");
Cookie cookie = new Cookie(name, str);
cookie.setPath(path);
cookie.setMaxAge(maxAge);
response.addCookie(cookie);
}
- 2 回答
- 0 關(guān)注
- 602 瀏覽
添加回答
舉報(bào)
0/150
提交
取消