Class CookieWebSessionIdResolver
- java.lang.Object
- org.springframework.web.server.session.CookieWebSessionIdResolver
- All Implemented Interfaces:
WebSessionIdResolver
public class CookieWebSessionIdResolver extends Object implements WebSessionIdResolver
Cookie-basedWebSessionIdResolver
.- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Brian Clozel
Constructor Summary
Constructors Constructor Description CookieWebSessionIdResolver()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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.Duration
getCookieMaxAge()
Return the configured "Max-Age" attribute value for the session cookie.String
getCookieName()
Return the configured cookie name.List<String>
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 Detail
CookieWebSessionIdResolver
public CookieWebSessionIdResolver()
Method Detail
setCookieName
public void setCookieName(String cookieName)
Set the name of the cookie to use for the session id.By default set to "SESSION".
- Parameters:
cookieName
- the cookie name
getCookieName
public String getCookieName()
Return the configured cookie name.
setCookieMaxAge
public void setCookieMaxAge(Duration maxAge)
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
public Duration getCookieMaxAge()
Return the configured "Max-Age" attribute value for the session cookie.
addCookieInitializer
public void addCookieInitializer(Consumer<ResponseCookie.ResponseCookieBuilder> initializer)
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
public List<String> resolveSessionIds(ServerWebExchange exchange)
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
public void setSessionId(ServerWebExchange exchange, String id)
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
public void expireSession(ServerWebExchange exchange)
Description copied from interface:WebSessionIdResolver
Instruct the client to end the current session.- Specified by:
expireSession
in interfaceWebSessionIdResolver
- Parameters:
exchange
- the current exchange