1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /** * 读取cookie * @param request * @return */ public static String readLoginToken(HttpServletRequest request) { Cookie[] cookie = request.getCookies(); System.out.println(cookie[ 0 ].getValue()); if (cookie != null ) { for (Cookie ck : cookie) { log.info( "write cookieName:{}, cookieValue:{}" , ck.getName(), ck.getValue()); if (StringUtils.equals(ck.getName(),COOKIE_NAME)){ log.info( "return cookieName:{},cookieValue:{}" ,ck.getName(),ck.getValue()); return ck.getValue(); } } } return null ; } |
正常登录之后已经存进去了。
但是再次发请求就变成这样了
请求头中也只有这个JESSIONID而不是我自己设置的name值