public class CookieWebSessionIdResolver extends java.lang.Object implements WebSessionIdResolver
WebSessionIdResolver
.Constructor and Description |
---|
CookieWebSessionIdResolver() |
Modifier and Type | Method and Description |
---|---|
void |
addCookieInitializer(java.util.function.Consumer<ResponseCookie.ResponseCookieBuilder> initializer)
Add a
Consumer for a ResponseCookieBuilder that will be invoked
for each cookie being built, just before the call to build() . |
void |
expireSession(ServerWebExchange exchange)
Instruct the client to end the current session.
|
java.time.Duration |
getCookieMaxAge()
Return the configured "Max-Age" attribute value for the session cookie.
|
java.lang.String |
getCookieName()
Return the configured cookie name.
|
java.util.List<java.lang.String> |
resolveSessionIds(ServerWebExchange exchange)
Resolve the session id's associated with the request.
|
void |
setCookieMaxAge(java.time.Duration maxAge)
Set the value for the "Max-Age" attribute of the cookie that holds the
session id.
|
void |
setCookieName(java.lang.String cookieName)
Set the name of the cookie to use for the session id.
|
void |
setSessionId(ServerWebExchange exchange,
java.lang.String id)
Send the given session id to the client.
|
public void setCookieName(java.lang.String cookieName)
By default set to "SESSION".
cookieName
- the cookie namepublic java.lang.String getCookieName()
public void setCookieMaxAge(java.time.Duration maxAge)
ResponseCookie.getMaxAge()
.
By default set to -1.
maxAge
- the maxAge duration valuepublic java.time.Duration getCookieMaxAge()
public void addCookieInitializer(java.util.function.Consumer<ResponseCookie.ResponseCookieBuilder> initializer)
Consumer
for a ResponseCookieBuilder
that will be invoked
for each cookie being built, just before the call to build()
.initializer
- consumer for a cookie builderpublic java.util.List<java.lang.String> resolveSessionIds(ServerWebExchange exchange)
WebSessionIdResolver
resolveSessionIds
in interface WebSessionIdResolver
exchange
- the current exchangepublic void setSessionId(ServerWebExchange exchange, java.lang.String id)
WebSessionIdResolver
setSessionId
in interface WebSessionIdResolver
exchange
- the current exchangeid
- the session idpublic void expireSession(ServerWebExchange exchange)
WebSessionIdResolver
expireSession
in interface WebSessionIdResolver
exchange
- the current exchange