protected function removeExpiredCookies($host, $path)
    {
        $time = new DateTimeImmutable('now', new DateTimeZone('UTC'));
        $hostPattern = '/' . preg_quote($host, '/') . '$/';

        foreach ($this->cookies as $i => $cookie) {
            $expired = $cookie->isExpired($time);
            $pathMatches = strpos($path, $cookie->getPath()) === 0;
            $hostMatches = preg_match($hostPattern, $cookie->getDomain());
            if ($pathMatches && $hostMatches && $expired) {
                unset($this->cookies[$i]);
            }
        }
    }
protected function removeExpiredCookies($host, $path)
    {
        $time = new DateTimeImmutable('now', new DateTimeZone('UTC'));
        $hostPattern = '/' . preg_quote($host, '/') . '$/';

        foreach ($this->cookies as $i => $cookie) {
            $expired = $cookie->isExpired($time);
            $pathMatches = strpos($path, $cookie->getPath()) === 0;
            $hostMatches = preg_match($hostPattern, $cookie->getDomain());
            if ($pathMatches && $hostMatches && $expired) {
                unset($this->cookies[$i]);
            }
        }
    }
protected function removeExpiredCookies ( $ host , $ path ) { $ time = new DateTimeImmutable ( 'now' , new DateTimeZone ( 'UTC' ) ) ; $ hostPattern = '/' . preg_quote ( $ host , '/' ) . '$/' ; foreach ( $ this -> cookies as $ i => $ cookie ) { $ expired = $ cookie -> isExpired ( $ time ) ; $ pathMatches = strpos ( $ path , $ cookie -> getPath ( ) ) === 0 ; $ hostMatches = preg_match ( $ hostPattern , $ cookie -> getDomain ( ) ) ; if ( $ pathMatches && $ hostMatches && $ expired ) { unset ( $ this -> cookies [ $ i ] ) ; } } }
Remove expired cookies from the collection.

@param string $host The host to check for expired cookies on.
@param string $path The path to check for expired cookies on.
@return void
Remove expired cookies from the collection .