/* */ package com.archive.common.utils ; /* */ /* */ import java.io.UnsupportedEncodingException; /* */ import java.net.URLDecoder; /* */ import java.net.URLEncoder; /* */ import javax.servlet.http.Cookie; /* */ import javax.servlet.http.HttpServletRequest; /* */ import javax.servlet.http.HttpServletResponse; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class CookieUtils /* */ { /* */ public static void setCookie(HttpServletResponse response, String name, String value) { /* 25 */ setCookie(response, name, value, 86400); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static void setCookie(HttpServletResponse response, String name, String value, String path) { /* 38 */ setCookie(response, name, value, path, 86400); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static void setCookie(HttpServletResponse response, String name, String value, int maxAge) { /* 51 */ setCookie(response, name, value, "/", maxAge); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static void setCookie(HttpServletResponse response, String name, String value, String path, int maxAge) { /* 64 */ Cookie cookie = new Cookie(name, null); /* 65 */ cookie.setPath(path); /* 66 */ cookie.setMaxAge(maxAge); /* */ /* */ try { /* 69 */ cookie.setValue(URLEncoder.encode(value, "utf-8")); /* */ } /* 71 */ catch (UnsupportedEncodingException e) { /* */ /* 73 */ e.printStackTrace(); /* */ } /* 75 */ response.addCookie(cookie); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static String getCookie(HttpServletRequest request, String name) { /* 86 */ return getCookie(request, null, name, false); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static String getCookie(HttpServletRequest request, HttpServletResponse response, String name) { /* 97 */ return getCookie(request, response, name, true); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static String getCookie(HttpServletRequest request, HttpServletResponse response, String name, boolean isRemove) { /* 112 */ String value = null; /* 113 */ Cookie[] cookies = request.getCookies(); /* 114 */ if (cookies != null) /* */ { /* 116 */ for (Cookie cookie : cookies) { /* */ /* 118 */ if (cookie.getName().equals(name)) { /* */ /* */ /* */ try { /* 122 */ value = URLDecoder.decode(cookie.getValue(), "utf-8"); /* */ } /* 124 */ catch (UnsupportedEncodingException e) { /* */ /* 126 */ e.printStackTrace(); /* */ } /* 128 */ if (isRemove) { /* */ /* 130 */ cookie.setMaxAge(0); /* 131 */ response.addCookie(cookie); /* */ } /* */ } /* */ } /* */ } /* 136 */ return value; /* */ } /* */ } /* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\commo\\utils\CookieUtils.class * Java compiler version: 8 (52.0) * JD-Core Version: 1.1.3 */