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

大話西游666
TA貢獻1817條經驗 獲得超14個贊
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 關注
- 593 瀏覽
添加回答
舉報
0/150
提交
取消