清除頑固cookie問題

本週我作的一個功能解綁當前用戶的功能的cookie清除不乾淨,致使用戶沒法正常退出‘ html

清除cookie代碼 java

String path="/";
 String domain=request.getServerName();
 domain = Common.handleServerName(domain);
 Cookie[] cookies=request.getCookies(); 
 for (Cookie cookie : cookies) {
 path=StringUtil.isBlank(cookie.getPath())?path:cookie.getPath();
 domain=StringUtil.isBlank(cookie.getDomain())?domain:cookie.getDomain();
 logger.info(cookie.getName()+"--cookie被清除,路徑爲:"+path+",域名爲:"+domain+",value:"+cookie.getValue());
 response=CookieUtil.clearCookie(request, response, cookie.getName(),domain,path);
 }
/**
	 * 清除cookie
	 * */
	public static HttpServletResponse clearCookie(HttpServletRequest request,HttpServletResponse response,String name,String domain,String path){
		
		Cookie cookie=new Cookie(name,null);
		cookie.setMaxAge(0);
		cookie.setPath(path);
		cookie.setDomain(domain);
		response.addCookie(cookie);
		return response;
	}

可是老是有一個cookie怎麼也清不掉,並且保存cookie的時候也沒見到過。 cookie

後邊發現,原來是保存在下邊的一段cookie,原來是這裏的cookie問題 dom

<meta http-equiv="Content-Type"content="text/html; charset=utf-8" />
<meta http-equiv=Set-Cookie

content='ddlibCookieName=102433.407238.%E8%8A%9C%E6%B9%96%E5%B8%82%E5%9B%BE%E4%B9%A6%E9%A6%86.9489fa1fb443e34a.261.5.13487; expires=Tue,1 Aug 2023 10:31:24 GMT; path=/;domain=whstsg.ddlib.com' / ui




最後找到這個頁面保存cookie的地方,改掉了這裏的bug


問題迎刃而解。
spa

相關文章
相關標籤/搜索