Package be.personify.util.http
Class CookieUtil
java.lang.Object
be.personify.util.http.CookieUtil
Class to get and set cookies
- Author:
- vanderw
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic jakarta.servlet.http.CookieGets a cookiestatic StringgetCookieValue(jakarta.servlet.http.HttpServletRequest request, String name) Returns the value of a cookie if presentstatic voidsetCookie(jakarta.servlet.http.HttpServletResponse response, String name, String value, String path, int expirySeconds, boolean secure, String domain) Sets a cookie
-
Constructor Details
-
CookieUtil
public CookieUtil()
-
-
Method Details
-
getCookie
public static jakarta.servlet.http.Cookie getCookie(jakarta.servlet.http.HttpServletRequest request, String name) Gets a cookie- Parameters:
request- the HttpServletRequestname- the name of the cookie- Returns:
- the cookie
-
getCookieValue
Returns the value of a cookie if present- Parameters:
request- the HttpServletRequestname- the name of the cookie- Returns:
- the value of the cookie with the name specified
-
setCookie
public static void setCookie(jakarta.servlet.http.HttpServletResponse response, String name, String value, String path, int expirySeconds, boolean secure, String domain) Sets a cookie- Parameters:
response- the HttpServletResponsename- the name of the cookievalue- the value of the cookiepath- the patch of the cookieexpirySeconds- the expiry time of the cookie in secondssecure- indicating if it has to be securedomain- the domain on which the cookie has to be set
-