Amp\Artax\Cookie\ArrayCookieJar::get PHP Method

get() public method

Retrieve all cookies matching the specified constraints
public get ( string $domain, string $path = '', string $name = null ) : array
$domain string
$path string
$name string
return array Returns an array (possibly empty) of all cookie matches
    public function get($domain, $path = '', $name = null)
    {
        $this->clearExpiredCookies();
        $path = $path === '' ? '/' : $path;
        $domain = strtolower($domain);
        $domainMatches = array();
        foreach (array_keys($this->cookies) as $cookieDomain) {
            if ($this->matchesDomain($domain, $cookieDomain)) {
                $domainMatches[] = $cookieDomain;
            }
        }
        $pathMatches = array();
        foreach ($domainMatches as $cookieDomain) {
            $paths = array_keys($this->cookies[$cookieDomain]);
            foreach ($paths as $cookiePath) {
                if ($this->matchesPath($path, $cookiePath)) {
                    $pathMatches[] = $this->cookies[$cookieDomain][$cookiePath];
                }
            }
        }
        $matches = array();
        foreach ($pathMatches as $nameArr) {
            foreach ($nameArr as $cookieName => $cookie) {
                if (!isset($name) || $name === $cookieName) {
                    $matches[] = $cookie;
                }
            }
        }
        return $matches;
    }