public class CookieWebSessionIdResolver extends Object implements WebSessionIdResolver
WebSessionIdResolver
.Constructor and Description |
---|
CookieWebSessionIdResolver() |
Modifier and Type | Method and Description |
---|---|
void |
addCookieInitializer(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.
|
Duration |
getCookieMaxAge()
Get the configured "Max-Age" attribute value for the session cookie.
|
String |
getCookieName()
Get the configured cookie name.
|
List<String> |
resolveSessionIds(ServerWebExchange exchange)
Resolve the session IDs 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.
|
public void setCookieName(String cookieName)
By default set to "SESSION".
cookieName
- the cookie namepublic String getCookieName()
public void setCookieMaxAge(Duration maxAge)
For the range of values see ResponseCookie.getMaxAge()
.
By default set to -1.
maxAge
- the maxAge duration valuepublic Duration getCookieMaxAge()
public void addCookieInitializer(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 List<String> resolveSessionIds(ServerWebExchange exchange)
WebSessionIdResolver
resolveSessionIds
in interface WebSessionIdResolver
exchange
- the current exchangepublic void setSessionId(ServerWebExchange exchange, 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