List of usage examples for javax.servlet.http Cookie setMaxAge
public void setMaxAge(int expiry)
From source file:org.tsm.concharto.auth.AuthHelper.java
public static void setCookie(HttpServletResponse response, String cookieName, int maxAge, String value) { Cookie cookie = new Cookie(cookieName, value); cookie.setMaxAge(maxAge); response.addCookie(cookie);/* w w w. j a v a 2 s.c o m*/ }
From source file:CookieUtils.java
/** * Adds a cookie with the specified name, value and expiry. * * @param response the HttpServletResponse to add the cookie to * @param name the name of the cookie * @param value the value of the cookie * @param maxAge the maxAge of the cookie (in seconds) *///from w ww . j a va2s .c o m public static void addCookie(HttpServletResponse response, String name, String value, int maxAge) { Cookie cookie = new Cookie(name, value); cookie.setMaxAge(maxAge); response.addCookie(cookie); }
From source file:architecture.ee.web.util.CookieUtils.java
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String name, String value, int maxAge) { if (value == null) value = ""; String path = request.getContextPath() != null ? request.getContextPath() : "/"; if ("".equals(path)) path = "/"; Cookie cookie = new Cookie(name, value); cookie.setMaxAge(maxAge); cookie.setPath(path);//from ww w . j a v a 2 s. com response.addCookie(cookie); }
From source file:com.eryansky.common.web.utils.RequestUtil.java
public static void deleteCookie(HttpServletResponse response, Cookie cookie, String path) { if (cookie != null) { cookie.setMaxAge(0); cookie.setPath(path);//from ww w . j a va 2 s . c o m response.addCookie(cookie); } }
From source file:ru.org.linux.csrf.CSRFProtectionService.java
public static void generateCSRFCookie(HttpServletRequest request, HttpServletResponse response) { SecureRandom random = new SecureRandom(); byte[] value = new byte[16]; random.nextBytes(value);//from w w w . j a v a 2s . c o m String token = new String(Base64.encodeBase64(value)); Cookie cookie = new Cookie(CSRF_COOKIE, token); cookie.setMaxAge(TWO_YEARS); cookie.setPath("/"); response.addCookie(cookie); request.setAttribute(CSRF_ATTRIBUTE, token); }
From source file:com.kamike.misc.CookieUtils.java
/** * * COOKIE/*from w ww . j av a 2 s . c om*/ * * * * @param name * * @param value * * @param maxAge * */ public static void setCookie(HttpServletRequest request, HttpServletResponse response, String name, String value, int maxAge) { Cookie cookie = new Cookie(name, value); cookie.setMaxAge(maxAge); cookie.setPath("/"); response.addCookie(cookie); }
From source file:com.ieasy.basic.util.CookieSupport.java
/** * cookies//from w ww . j ava2 s .c o m * * @param response * @param cookieParams * @param maxAge */ public static final void writeCookies(HttpServletResponse response, Map<String, String> cookieParams, int maxAge) { if (cookieParams == null || cookieParams.size() == 0) return; Set<String> keySet = cookieParams.keySet(); for (String key : keySet) { Cookie cookie = new Cookie(key, cookieParams.get(key)); cookie.setMaxAge(maxAge); response.addCookie(cookie); } }
From source file:org.examproject.tweet.controller.SettingController.java
private static void storeTokenToCookie(TweetForm tweetForm, HttpServletResponse response, int maxAge) { Cookie cookie = new Cookie(TweetCookie.USER_LIST_NAME.getName(), tweetForm.getUserListName()); cookie.setMaxAge(maxAge); response.addCookie(cookie);/*from w w w.j a va 2 s .c o m*/ cookie = new Cookie(TweetCookie.RESPONSE_LIST_MODE.getName(), tweetForm.getResponseListMode()); cookie.setMaxAge(maxAge); response.addCookie(cookie); }
From source file:net.mindengine.oculus.frontend.web.Auth.java
private static Cookie createCookie(String name, String value, int maxAge, String path) { Cookie cookie = new Cookie(name, value); cookie.setMaxAge(maxAge); cookie.setPath(path);/*w w w . j a va2s . c o m*/ return cookie; }
From source file:com.leixl.easyframework.web.CookieUtils.java
/** * ?cookie// w ww . ja v a2s. c o m * * @param request * @param response * @param name * @param domain */ public static void cancleCookie(HttpServletRequest request, HttpServletResponse response, String name, String domain) { Cookie cookie = new Cookie(name, ""); cookie.setMaxAge(0); String ctx = request.getContextPath(); cookie.setPath(StringUtils.isBlank(ctx) ? "/" : ctx); if (StringUtils.isNotBlank(domain)) { cookie.setDomain(domain); } response.addCookie(cookie); }