package com.ywt.mg.web;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by huangguoping.
 */
public class CookiesHelper {
    public static Map<String,Cookie> getCookiesDict(HttpServletRequest httpServletRequest){
        Cookie[] cookies = httpServletRequest.getCookies();
        if (cookies != null && cookies.length > 0){
            Map<String, Cookie> map = new HashMap<>();
            for (Cookie cookie : cookies){
                if (cookie.getName() == null || cookie.getName().equals("")) continue;
                map.put(cookie.getName(), cookie);
            }
            return map;
        }
        return null;
    }
}
