public function getCookie($key, $domain = '-')
    {
        $domain = strtolower($domain);
        if ($key === null) {
            $cookies = [];
        }
        while (true) {
            if (isset($this->_cookies[$domain])) {
                foreach ($this->_cookies[$domain] as $path => $list) {
                    if ($key === null) {
                        $cookies = array_merge($list, $cookies);
                    } else {
                        if (isset($list[$key])) {
                            return rawurldecode($list[$key]['value']);
                        }
                    }
                }
            }
            if (($pos = strpos($domain, '.', 1)) === false) {
                break;
            }
            $domain = substr($domain, $pos);
        }
        return $key === null ? $cookies : null;
    }
public function getCookie($key, $domain = '-')
    {
        $domain = strtolower($domain);
        if ($key === null) {
            $cookies = [];
        }
        while (true) {
            if (isset($this->_cookies[$domain])) {
                foreach ($this->_cookies[$domain] as $path => $list) {
                    if ($key === null) {
                        $cookies = array_merge($list, $cookies);
                    } else {
                        if (isset($list[$key])) {
                            return rawurldecode($list[$key]['value']);
                        }
                    }
                }
            }
            if (($pos = strpos($domain, '.', 1)) === false) {
                break;
            }
            $domain = substr($domain, $pos);
        }
        return $key === null ? $cookies : null;
    }
public function getCookie ( $ key , $ domain = '-' ) { $ domain = strtolower ( $ domain ) ; if ( $ key === null ) { $ cookies = [ ] ; } while ( true ) { if ( isset ( $ this -> _cookies [ $ domain ] ) ) { foreach ( $ this -> _cookies [ $ domain ] as $ path => $ list ) { if ( $ key === null ) { $ cookies = array_merge ( $ list , $ cookies ) ; } else { if ( isset ( $ list [ $ key ] ) ) { return rawurldecode ( $ list [ $ key ] [ 'value' ] ) ; } } } } if ( ( $ pos = strpos ( $ domain , '.' , 1 ) ) === false ) { break ; } $ domain = substr ( $ domain , $ pos ) ; } return $ key === null ? $ cookies : null ; }
Get cookie value
@param string $key passing null to get all cookies
@param string $domain passing '-' to fetch from current session,
@return array|null|string
Get cookie value