美文网首页
坑爹,spring-session的sessionId是Base

坑爹,spring-session的sessionId是Base

作者: 萧萧飞叶 | 来源:发表于2019-04-13 05:09 被阅读0次

    坑爹,spring-session的sessionId是 base64编码的
    写入cookie前要先用base64编码,
    这样spring-session才能解码使用

        @Override
        public List<String> readCookieValues(HttpServletRequest request) {
            Cookie[] cookies = request.getCookies();
            List<String> matchingCookieValues = new ArrayList<>();
            if (cookies != null) {
                for (Cookie cookie : cookies) {
                    if (this.cookieName.equals(cookie.getName())) {
                        String sessionId = (this.useBase64Encoding
                                ? base64Decode(cookie.getValue())
                                : cookie.getValue());
                        if (sessionId == null) {
                            continue;
                        }
                        if (this.jvmRoute != null && sessionId.endsWith(this.jvmRoute)) {
                            sessionId = sessionId.substring(0,
                                    sessionId.length() - this.jvmRoute.length());
                        }
                        matchingCookieValues.add(sessionId);
                    }
                }
            }
            return matchingCookieValues;
        }
    

    相关文章

      网友评论

          本文标题:坑爹,spring-session的sessionId是Base

          本文链接:https://www.haomeiwen.com/subject/ipvkwqtx.html