package com.szxgl.nft.utils;

import com.szxgl.nft.exception.ParameterException;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.Cookie;

@Slf4j
public class CookieUtil {

    public static String getCookie(Cookie[] cookies){
        if(cookies == null || cookies.length == 0){
            log.error("cookies为空");
            throw new ParameterException("cookies为空");
        }
        String value = "";
        for (Cookie cookie : cookies) {
            if("openid".equals(cookie.getName())){
                value = cookie.getValue();
            }
        }
        return value;
    }

}
