public function matchCookie($name, $pattern = null)
    {
        if (isset($this->getCookies()[$name])) {
            if (!empty($pattern)) {
                if ($this->matchValue($this->getCookies()[$name], $pattern)) {
                    return $this->getCookies()[$name];
                }
            } else {
                if (empty($this->getCookies()[$name])) {
                    return true;
                } else {
                    return $this->getCookies()[$name];
                }
            }
        } elseif ($pattern == '?') {
            // in case of optional pattern we just return true
            return true;
        }

        return false;
    }
public function matchCookie($name, $pattern = null)
    {
        if (isset($this->getCookies()[$name])) {
            if (!empty($pattern)) {
                if ($this->matchValue($this->getCookies()[$name], $pattern)) {
                    return $this->getCookies()[$name];
                }
            } else {
                if (empty($this->getCookies()[$name])) {
                    return true;
                } else {
                    return $this->getCookies()[$name];
                }
            }
        } elseif ($pattern == '?') {
            // in case of optional pattern we just return true
            return true;
        }

        return false;
    }
public function matchCookie ( $ name , $ pattern = null ) { if ( isset ( $ this -> getCookies ( ) [ $ name ] ) ) { if ( ! empty ( $ pattern ) ) { if ( $ this -> matchValue ( $ this -> getCookies ( ) [ $ name ] , $ pattern ) ) { return $ this -> getCookies ( ) [ $ name ] ; } } else { if ( empty ( $ this -> getCookies ( ) [ $ name ] ) ) { return true ; } else { return $ this -> getCookies ( ) [ $ name ] ; } } } elseif ( $ pattern == '?' ) { // in case of optional pattern we just return true return true ; } return false ; }
Check if the given cookie exists, and optionally if the pattern matches the cookie value.

@param string      $name Cookie name to match.
@param string|null $pattern Optional pattern that needs to match the cookie value.

@return bool|string  False if the cookie doesn't exist, or the pattern doesn't match.
If the cookie exists and pattern matched, the cookie value is returned.
Check if the given cookie exists and optionally if the pattern matches the cookie value .