public function Cookie::__toString

Returns the cookie as a string.

Return value

string The cookie

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Cookie.php, line 80

Class

Cookie
Represents a cookie

Namespace

Symfony\Component\HttpFoundation

Code

public function __toString() {
  $str = urlencode($this
    ->getName()) . '=';
  if ('' === (string) $this
    ->getValue()) {
    $str .= 'deleted; expires=' . gmdate("D, d-M-Y H:i:s T", time() - 31536001);
  }
  else {
    $str .= urlencode($this
      ->getValue());
    if ($this
      ->getExpiresTime() !== 0) {
      $str .= '; expires=' . gmdate("D, d-M-Y H:i:s T", $this
        ->getExpiresTime());
    }
  }
  if ('/' !== $this->path) {
    $str .= '; path=' . $this->path;
  }
  if (null !== $this
    ->getDomain()) {
    $str .= '; domain=' . $this
      ->getDomain();
  }
  if (true === $this
    ->isSecure()) {
    $str .= '; secure';
  }
  if (true === $this
    ->isHttpOnly()) {
    $str .= '; httponly';
  }
  return $str;
}