3 回答

TA貢獻1946條經驗 獲得超4個贊
cookie.setPath(path);//根據你創建cookie的路徑進行填寫
response.addCookie(cookie); } }catch(Exception ex) {
System.out.println(“刪除Cookies發生異常!”); } } public static void setCookie(HttpServletResponse response, String name, String value, String path) {
if (logger.isDebugEnabled()) {
logger.debug(“Setting cookie ’” + name + “‘ on path ’” + path + “‘”); } Cookie cookie = new Cookie(name, value);
cookie.setSecure(false);
cookie.setPath(path);
cookie.setMaxAge(Constants.COOKIE_INVALID_TIME);
response.addCookie(cookie);
// logger.info(”setCookie 完成…….”); } //調用 String cookiename = “vbo”;
String cookievalue = “cb”;
String path = “/”;
setCookie(response, cookiename , cookievalue , path);
clearCookie(request,response,path);//如果有name的話,方法也要增加name過去才能匹配
添加回答
舉報