public function Request::addCookie

Add a Cookie value by name to the Cookie header

Parameters

string $name Name of the cookie to add:

string $value Value to set:

Return value

RequestInterface

Overrides RequestInterface::addCookie

File

drupal/core/vendor/guzzle/http/Guzzle/Http/Message/Request.php, line 586

Class

Request
HTTP request class to send requests

Namespace

Guzzle\Http\Message

Code

public function addCookie($name, $value) {
  if (!$this
    ->hasHeader('Cookie')) {
    $this
      ->setHeader('Cookie', "{$name}={$value}");
  }
  else {
    $this
      ->getHeader('Cookie')
      ->add("{$name}={$value}");
  }

  // Always use semicolons to separate multiple cookie headers
  $this
    ->getHeader('Cookie')
    ->setGlue('; ');
  return $this;
}