坑爹,spring-session的sessionId是Base64编码的

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

    @Override
    public List readCookieValues(HttpServletRequest request) {
        Cookie[] cookies = request.getCookies();
        List 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是Base64编码的)