You are here

public static function CookieJar::fromArray in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php \GuzzleHttp\Cookie\CookieJar::fromArray()

Create a new Cookie jar from an associative array and domain.

Parameters

array $cookies Cookies to create the jar from:

string $domain Domain to set the cookies to:

Return value

self

1 call to CookieJar::fromArray()
Client::doRequest in vendor/fabpot/goutte/Goutte/Client.php

File

vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php, line 45

Class

CookieJar
Cookie jar that stores cookies an an array

Namespace

GuzzleHttp\Cookie

Code

public static function fromArray(array $cookies, $domain) {
  $cookieJar = new self();
  foreach ($cookies as $name => $value) {
    $cookieJar
      ->setCookie(new SetCookie([
      'Domain' => $domain,
      'Name' => $name,
      'Value' => $value,
      'Discard' => true,
    ]));
  }
  return $cookieJar;
}