Class CookieWebSessionIdResolver
java.lang.Object
org.springframework.web.server.session.CookieWebSessionIdResolver
- All Implemented Interfaces:
WebSessionIdResolver
Cookie-based
WebSessionIdResolver
.- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Brian Clozel
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCookieInitializer
(Consumer<ResponseCookie.ResponseCookieBuilder> initializer) Add aConsumer
for aResponseCookieBuilder
that will be invoked for each cookie being built, just before the call tobuild()
.void
expireSession
(ServerWebExchange exchange) Instruct the client to end the current session.Return the configured "Max-Age" attribute value for the session cookie.Return the configured cookie name.resolveSessionIds
(ServerWebExchange exchange) Resolve the session id's associated with the request.void
setCookieMaxAge
(Duration maxAge) Set the value for the "Max-Age" attribute of the cookie that holds the session id.void
setCookieName
(String cookieName) Set the name of the cookie to use for the session id.void
setSessionId
(ServerWebExchange exchange, String id) Send the given session id to the client.
-
Constructor Details
-
CookieWebSessionIdResolver
public CookieWebSessionIdResolver()
-
-
Method Details
-
setCookieName
Set the name of the cookie to use for the session id.By default set to "SESSION".
- Parameters:
cookieName
- the cookie name
-
getCookieName
Return the configured cookie name. -
setCookieMaxAge
Set the value for the "Max-Age" attribute of the cookie that holds the session id. For the range of values seeResponseCookie.getMaxAge()
.By default set to -1.
- Parameters:
maxAge
- the maxAge duration value
-
getCookieMaxAge
Return the configured "Max-Age" attribute value for the session cookie. -
addCookieInitializer
Add aConsumer
for aResponseCookieBuilder
that will be invoked for each cookie being built, just before the call tobuild()
.- Parameters:
initializer
- consumer for a cookie builder- Since:
- 5.1
-
resolveSessionIds
Description copied from interface:WebSessionIdResolver
Resolve the session id's associated with the request.- Specified by:
resolveSessionIds
in interfaceWebSessionIdResolver
- Parameters:
exchange
- the current exchange- Returns:
- the session id's or an empty list
-
setSessionId
Description copied from interface:WebSessionIdResolver
Send the given session id to the client.- Specified by:
setSessionId
in interfaceWebSessionIdResolver
- Parameters:
exchange
- the current exchangeid
- the session id
-
expireSession
Description copied from interface:WebSessionIdResolver
Instruct the client to end the current session.- Specified by:
expireSession
in interfaceWebSessionIdResolver
- Parameters:
exchange
- the current exchange
-