Package ratpack.session
Class SessionCookieConfig
- java.lang.Object
-
- ratpack.session.SessionCookieConfig
-
public class SessionCookieConfig extends Object
Basic configuration for cookies related to session management.Attributes are shared with
ClientSideSessionConfig
that is used by client side session (cookie based).- See Also:
ClientSideSessionConfig
-
-
Constructor Summary
Constructors Constructor Description SessionCookieConfig()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SessionCookieConfig
domain(String domain)
Set thedomain
for session cookie.SessionCookieConfig
expires(Duration expiresDuration)
Set max age of the cookies related to session management.String
getDomain()
Use the session cookie only when requesting from thedomain
.Duration
getExpires()
Cookie's max age.String
getIdName()
The name of the cookie for session id.String
getPath()
Use the session cookie only when requesting from thepath
.SessionCookieConfig
httpOnly(boolean httpOnly)
Set session cookies attributeHttpOnly
.SessionCookieConfig
idName(String idName)
Set the name of the cookie for session id.boolean
isHttpOnly()
HttpOnly
cookies can only be used when transmitted viaHTTP/HTTPS
.boolean
isSecure()
Secure
cookies can only be transmitted over encrypted connection likeHTTPS
.SessionCookieConfig
path(String path)
Set thepath
for session cookie.SessionCookieConfig
secure(boolean secure)
Set session cookies attributeSecure
.void
setDomain(String domain)
Set thedomain
for session cookie.void
setExpires(Duration expires)
Set cookie's max age.void
setHttpOnly(boolean httpOnly)
Set session cookies attributeHttpOnly
.void
setIdName(String idName)
Set the name of the cookie for session id.void
setPath(String path)
Set thepath
for session cookie.void
setSecure(boolean secure)
Set session cookies attributeSecure
.
-
-
-
Method Detail
-
getExpires
public Duration getExpires()
Cookie's max age.- Returns:
- the max age of the session related cookies
-
getDomain
public String getDomain()
Use the session cookie only when requesting from thedomain
.Define the scope for the cookie.
- Returns:
- the URI domain to which session cookie will be attached to.
-
getPath
public String getPath()
Use the session cookie only when requesting from thepath
.Define the scope of the cookie.
Session should be send for every request. The
path
of value"/"
does this.- Returns:
- the URI path to which session cookie will be attached to.
-
getIdName
public String getIdName()
The name of the cookie for session id.Defaults to:
JSESSIONID
- Returns:
- the name of the cookie for session id
-
isHttpOnly
public boolean isHttpOnly()
HttpOnly
cookies can only be used when transmitted viaHTTP/HTTPS
. They are not accessible forJavaScript
.Http only cookies have to be supported by the browser.
- Returns:
- true if client side session cookies are
HttpOnly
-
isSecure
public boolean isSecure()
Secure
cookies can only be transmitted over encrypted connection likeHTTPS
.- Returns:
- true if session cookies are
Secure
-
setExpires
public void setExpires(Duration expires)
Set cookie's max age.- Parameters:
expires
- the duration after cookie expires
-
setDomain
public void setDomain(String domain)
Set thedomain
for session cookie.Define the scope of the cookie
- Parameters:
domain
- a domain to which session cokkie will be attached to
-
setPath
public void setPath(String path)
Set thepath
for session cookie.Define the scope of the cookie.
- Parameters:
path
- a path to which session cookie will be attached to
-
setIdName
public void setIdName(String idName)
Set the name of the cookie for session id.- Parameters:
idName
- the name of the cookie for session id
-
setHttpOnly
public void setHttpOnly(boolean httpOnly)
Set session cookies attributeHttpOnly
.- Parameters:
httpOnly
- if true client side session cookies areHttpOnly
-
setSecure
public void setSecure(boolean secure)
Set session cookies attributeSecure
.- Parameters:
secure
- if true client side session cookies can be transmitted only over encrypted connection
-
expires
public SessionCookieConfig expires(Duration expiresDuration)
Set max age of the cookies related to session management.- Parameters:
expiresDuration
- the duration, max age, of the cookies related to session management- Returns:
- the config
-
domain
public SessionCookieConfig domain(String domain)
Set thedomain
for session cookie.Define the scope of the cookie
- Parameters:
domain
- a domain to which session cokkie will be attached to- Returns:
- the config
-
path
public SessionCookieConfig path(String path)
Set thepath
for session cookie.Define the scope of the cookie.
- Parameters:
path
- a path to which session cookie will be attached to- Returns:
- the config
-
idName
public SessionCookieConfig idName(String idName)
Set the name of the cookie for session id.- Parameters:
idName
- the name of the cookie for session id- Returns:
- the config
-
httpOnly
public SessionCookieConfig httpOnly(boolean httpOnly)
Set session cookies attributeHttpOnly
.- Parameters:
httpOnly
- if true client side session cookies areHttpOnly
- Returns:
- the config
-
secure
public SessionCookieConfig secure(boolean secure)
Set session cookies attributeSecure
.- Parameters:
secure
- if true client side session cookies can be transmitted only over encrypted connection- Returns:
- the config
-
-