@Immutable public final class CookieHelper extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_AGE_SECONDS |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
containsCookie(javax.servlet.http.HttpServletRequest aHttpRequest,
String sCookieName) |
static javax.servlet.http.Cookie |
createContextCookie(String sName,
String sValue,
boolean bExpireWhenBrowserIsClosed) |
static javax.servlet.http.Cookie |
createCookie(String sName,
String sValue,
String sPath,
boolean bExpireWhenBrowserIsClosed)
Create a cookie that is bound on a certain path within the local web
server.
|
static com.helger.commons.collection.impl.ICommonsOrderedMap<String,javax.servlet.http.Cookie> |
getAllCookies(javax.servlet.http.HttpServletRequest aHttpRequest) |
static javax.servlet.http.Cookie |
getCookie(javax.servlet.http.HttpServletRequest aHttpRequest,
String sCookieName) |
static void |
removeCookie(javax.servlet.http.HttpServletResponse aHttpResponse,
javax.servlet.http.Cookie aCookie)
Remove a cookie by setting the max age to 0.
|
public static final int DEFAULT_MAX_AGE_SECONDS
@Nonnull @ReturnsMutableCopy public static com.helger.commons.collection.impl.ICommonsOrderedMap<String,javax.servlet.http.Cookie> getAllCookies(@Nonnull javax.servlet.http.HttpServletRequest aHttpRequest)
@Nullable public static javax.servlet.http.Cookie getCookie(@Nonnull javax.servlet.http.HttpServletRequest aHttpRequest, @Nonnull String sCookieName)
public static boolean containsCookie(@Nonnull javax.servlet.http.HttpServletRequest aHttpRequest, @Nonnull String sCookieName)
@Nonnull public static javax.servlet.http.Cookie createCookie(@Nonnull String sName, @Nullable String sValue, String sPath, boolean bExpireWhenBrowserIsClosed)
sName - The cookie name.sValue - The cookie value.sPath - The path the cookie is valid for.bExpireWhenBrowserIsClosed - true if this is a browser session cookie@Nonnull public static javax.servlet.http.Cookie createContextCookie(@Nonnull String sName, @Nullable String sValue, boolean bExpireWhenBrowserIsClosed)
public static void removeCookie(@Nonnull javax.servlet.http.HttpServletResponse aHttpResponse, @Nonnull javax.servlet.http.Cookie aCookie)
aHttpResponse - The HTTP response. May not be null.aCookie - The cookie to be removed. May not be null.Copyright © 2016–2019 Philip Helger. All rights reserved.