类 CookieGenerator
java.lang.Object
cn.taketoday.web.servlet.CookieGenerator
- 直接已知子类:
CookieLocaleResolver
Helper class for cookie generation, carrying cookie descriptor settings
as bean properties and being able to add and remove cookie to/from a
given response.
- 从以下版本开始:
- 4.0
- 作者:
- Juergen Hoeller
- 另请参阅:
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidaddCookie(RequestContext response, String cookieValue) Add a cookie with the given value to the response, using the cookie descriptor settings of this generator.protected ResponseCookie.ResponseCookieBuildercreateCookie(String cookieValue) Create a cookie with the given value, using the cookie descriptor settings of this generator (except for "cookieMaxAge").Return the domain for cookies created by this generator, if any.Return the maximum age for cookies created by this generator.Return the given name for cookies created by this generator.Return the path for cookies created by this generator.booleanReturn whether the cookie is supposed to be marked with the "HttpOnly" attribute.booleanReturn whether the cookie should only be sent using a secure protocol, such as HTTPS (SSL).voidremoveCookie(RequestContext response) Remove the cookie that this generator describes from the response.voidsetCookieDomain(String cookieDomain) Use the given domain for cookies created by this generator.voidsetCookieHttpOnly(boolean cookieHttpOnly) Set whether the cookie is supposed to be marked with the "HttpOnly" attribute.voidsetCookieMaxAge(Integer cookieMaxAge) Use the given maximum age (in seconds) for cookies created by this generator.voidsetCookieName(String cookieName) Use the given name for cookies created by this generator.voidsetCookiePath(String cookiePath) Use the given path for cookies created by this generator.voidsetCookieSameSite(String cookieSameSite) Add the "SameSite" attribute to the cookie.voidsetCookieSecure(boolean cookieSecure) Set whether the cookie should only be sent using a secure protocol, such as HTTPS (SSL).
-
字段详细资料
-
DEFAULT_COOKIE_PATH
Default path that cookies will be visible to: "/", i.e. the entire server.- 另请参阅:
-
logger
protected final cn.taketoday.logging.Logger logger -
cookieName
-
cookieDomain
-
cookiePath
-
cookieMaxAge
-
cookieSecure
private boolean cookieSecure -
cookieHttpOnly
private boolean cookieHttpOnly -
cookieSameSite
-
-
构造器详细资料
-
CookieGenerator
public CookieGenerator()
-
-
方法详细资料
-
setCookieName
Use the given name for cookies created by this generator.- 另请参阅:
-
getCookieName
Return the given name for cookies created by this generator. -
setCookieDomain
Use the given domain for cookies created by this generator. The cookie is only visible to servers in this domain. -
getCookieDomain
Return the domain for cookies created by this generator, if any. -
setCookiePath
Use the given path for cookies created by this generator. The cookie is only visible to URLs in this path and below. -
getCookiePath
Return the path for cookies created by this generator. -
setCookieMaxAge
Use the given maximum age (in seconds) for cookies created by this generator. Useful special value: -1 ... not persistent, deleted when client shuts down.Default is no specific maximum age at all, using the Servlet container's default.
-
getCookieMaxAge
Return the maximum age for cookies created by this generator. -
setCookieSecure
public void setCookieSecure(boolean cookieSecure) Set whether the cookie should only be sent using a secure protocol, such as HTTPS (SSL). This is an indication to the receiving browser, not processed by the HTTP server itself.Default is "false".
-
isCookieSecure
public boolean isCookieSecure()Return whether the cookie should only be sent using a secure protocol, such as HTTPS (SSL). -
setCookieHttpOnly
public void setCookieHttpOnly(boolean cookieHttpOnly) Set whether the cookie is supposed to be marked with the "HttpOnly" attribute.Default is "false".
-
setCookieSameSite
Add the "SameSite" attribute to the cookie.By default, this is set to
"Lax". -
getCookieSameSite
-
isCookieHttpOnly
public boolean isCookieHttpOnly()Return whether the cookie is supposed to be marked with the "HttpOnly" attribute. -
addCookie
Add a cookie with the given value to the response, using the cookie descriptor settings of this generator.Delegates to
createCookie(java.lang.String)for cookie creation.- 参数:
response- the HTTP response to add the cookie tocookieValue- the value of the cookie to add- 另请参阅:
-
removeCookie
Remove the cookie that this generator describes from the response. Will generate a cookie with empty value and max age 0.Delegates to
createCookie(java.lang.String)for cookie creation.- 参数:
response- the HTTP response to remove the cookie from- 另请参阅:
-
createCookie
Create a cookie with the given value, using the cookie descriptor settings of this generator (except for "cookieMaxAge").- 参数:
cookieValue- the value of the cookie to crate- 返回:
- the cookie
- 另请参阅:
-