public function updateFromSetCookie(array $setCookies, $uri = null)
    {
        $cookies = [];

        foreach ($setCookies as $cookie) {
            foreach (explode(',', $cookie) as $i => $part) {
                if (0 === $i || preg_match('/^(?P<token>\s*[0-9A-Za-z!#\$%\&\'\*\+\-\.^_`\|~]+)=/', $part)) {
                    $cookies[] = ltrim($part);
                } else {
                    $cookies[\count($cookies) - 1] .= ','.$part;
                }
            }
        }

        foreach ($cookies as $cookie) {
            try {
                $this->set(Cookie::fromString($cookie, $uri));
            } catch (\InvalidArgumentException $e) {
                // invalid cookies are just ignored
            }
        }
    }
public function updateFromSetCookie(array $setCookies, $uri = null)
    {
        $cookies = [];

        foreach ($setCookies as $cookie) {
            foreach (explode(',', $cookie) as $i => $part) {
                if (0 === $i || preg_match('/^(?P<token>\s*[0-9A-Za-z!#\$%\&\'\*\+\-\.^_`\|~]+)=/', $part)) {
                    $cookies[] = ltrim($part);
                } else {
                    $cookies[\count($cookies) - 1] .= ','.$part;
                }
            }
        }

        foreach ($cookies as $cookie) {
            try {
                $this->set(Cookie::fromString($cookie, $uri));
            } catch (\InvalidArgumentException $e) {
                // invalid cookies are just ignored
            }
        }
    }
public function updateFromSetCookie ( array $ setCookies , $ uri = null ) { $ cookies = [ ] ; foreach ( $ setCookies as $ cookie ) { foreach ( explode ( ',' , $ cookie ) as $ i => $ part ) { if ( 0 === $ i || preg_match ( '/^(?P<token>\s*[0-9A-Za-z!#\$%\&\'\*\+\-\.^_`\|~]+)=/' , $ part ) ) { $ cookies [ ] = ltrim ( $ part ) ; } else { $ cookies [ \ count ( $ cookies ) - 1 ] .= ',' . $ part ; } } } foreach ( $ cookies as $ cookie ) { try { $ this -> set ( Cookie :: fromString ( $ cookie , $ uri ) ) ; } catch ( \ InvalidArgumentException $ e ) { // invalid cookies are just ignored } } }
Updates the cookie jar from a response Set-Cookie headers.

@param array  $setCookies Set-Cookie headers from an HTTP response
@param string $uri        The base URL
Updates the cookie jar from a response Set - Cookie headers .