Package org.springframework.http
Class ResponseCookie
java.lang.Object
org.springframework.http.HttpCookie
org.springframework.http.ResponseCookie
An 
HttpCookie subclass with the additional attributes allowed in
 the "Set-Cookie" response header. To build an instance use the from(java.lang.String, java.lang.String)
 static method.- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Brian Clozel
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceA builder for a server-defined HttpCookie with attributes.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanFactory method to obtain a builder for a server-defined cookie that starts with a name-value pair and may also include attributes.fromClientResponse(String name, String value) Factory method to obtain a builder for a server-defined cookie.Return the cookie "Domain" attribute, ornullif not set.Return the cookie "Max-Age" attribute in seconds.getPath()Return the cookie "Path" attribute, ornullif not set.Return the cookie "SameSite" attribute, ornullif not set.inthashCode()booleanReturntrueif the cookie has the "HttpOnly" attribute.booleanisSecure()Returntrueif the cookie has the "Secure" attribute.toString()Methods inherited from class org.springframework.http.HttpCookiegetName, getValue
- 
Method Details- 
getMaxAgeReturn the cookie "Max-Age" attribute in seconds.A positive value indicates when the cookie expires relative to the current time. A value of 0 means the cookie should expire immediately. A negative value means no "Max-Age" attribute in which case the cookie is removed when the browser is closed. 
- 
getDomainReturn the cookie "Domain" attribute, ornullif not set.
- 
getPathReturn the cookie "Path" attribute, ornullif not set.
- 
isSecurepublic boolean isSecure()Returntrueif the cookie has the "Secure" attribute.
- 
isHttpOnlypublic boolean isHttpOnly()Returntrueif the cookie has the "HttpOnly" attribute.- See Also:
 
- 
getSameSiteReturn the cookie "SameSite" attribute, ornullif not set.This limits the scope of the cookie such that it will only be attached to same site requests if "Strict"or cross-site requests if"Lax".- Since:
- 5.1
- See Also:
 
- 
equals- Overrides:
- equalsin class- HttpCookie
 
- 
hashCodepublic int hashCode()- Overrides:
- hashCodein class- HttpCookie
 
- 
toString- Overrides:
- toStringin class- HttpCookie
 
- 
fromFactory method to obtain a builder for a server-defined cookie that starts with a name-value pair and may also include attributes.- Parameters:
- name- the cookie name
- value- the cookie value
- Returns:
- a builder to create the cookie with
 
- 
fromClientResponseFactory method to obtain a builder for a server-defined cookie. Unlikefrom(String, String)this option assumes input from a remote server, which can be handled more leniently, e.g. ignoring a empty domain name with double quotes.- Parameters:
- name- the cookie name
- value- the cookie value
- Returns:
- a builder to create the cookie with
- Since:
- 5.2.5
 
 
-