Search in sources :

Example 1 with CookieValue

use of org.springframework.session.web.http.CookieSerializer.CookieValue in project spring-session by spring-projects.

the class DefaultCookieSerializerTests method writeCookieRememberMeCookieMaxAgeOverride.

@Test
public void writeCookieRememberMeCookieMaxAgeOverride() {
    this.request.setAttribute("rememberMe", true);
    this.serializer.setRememberMeRequestAttribute("rememberMe");
    CookieValue cookieValue = cookieValue(this.sessionId);
    cookieValue.setCookieMaxAge(100);
    this.serializer.writeCookieValue(cookieValue);
    assertThat(getCookie().getMaxAge()).isEqualTo(100);
}
Also used : CookieValue(org.springframework.session.web.http.CookieSerializer.CookieValue) Test(org.junit.Test)

Example 2 with CookieValue

use of org.springframework.session.web.http.CookieSerializer.CookieValue in project spring-session by spring-projects.

the class DefaultCookieSerializerTests method writeCookieCookieMaxAgeExplicitCookieValue.

@Test
public void writeCookieCookieMaxAgeExplicitCookieValue() {
    CookieValue cookieValue = cookieValue(this.sessionId);
    cookieValue.setCookieMaxAge(100);
    this.serializer.writeCookieValue(cookieValue);
    assertThat(getCookie().getMaxAge()).isEqualTo(100);
}
Also used : CookieValue(org.springframework.session.web.http.CookieSerializer.CookieValue) Test(org.junit.Test)

Example 3 with CookieValue

use of org.springframework.session.web.http.CookieSerializer.CookieValue in project spring-session by spring-projects.

the class CookieHttpSessionIdResolver method setSessionId.

@Override
public void setSessionId(HttpServletRequest request, HttpServletResponse response, String sessionId) {
    if (sessionId.equals(request.getAttribute(WRITTEN_SESSION_ID_ATTR))) {
        return;
    }
    request.setAttribute(WRITTEN_SESSION_ID_ATTR, sessionId);
    this.cookieSerializer.writeCookieValue(new CookieValue(request, response, sessionId));
}
Also used : CookieValue(org.springframework.session.web.http.CookieSerializer.CookieValue)

Aggregations

CookieValue (org.springframework.session.web.http.CookieSerializer.CookieValue)3 Test (org.junit.Test)2