You are here

public function Cookie::__toString in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/http-foundation/Cookie.php \Symfony\Component\HttpFoundation\Cookie::__toString()
  2. 8 vendor/symfony/browser-kit/Cookie.php \Symfony\Component\BrowserKit\Cookie::__toString()
Same name and namespace in other branches
  1. 8.0 vendor/symfony/browser-kit/Cookie.php \Symfony\Component\BrowserKit\Cookie::__toString()

Returns the HTTP representation of the Cookie.

Return value

string The HTTP representation of the Cookie

Throws

\UnexpectedValueException

File

vendor/symfony/browser-kit/Cookie.php, line 90

Class

Cookie
Cookie represents an HTTP cookie.

Namespace

Symfony\Component\BrowserKit

Code

public function __toString() {
  $cookie = sprintf('%s=%s', $this->name, $this->rawValue);
  if (null !== $this->expires) {
    $dateTime = \DateTime::createFromFormat('U', $this->expires, new \DateTimeZone('GMT'));
    $cookie .= '; expires=' . str_replace('+0000', '', $dateTime
      ->format(self::$dateFormats[0]));
  }
  if ('' !== $this->domain) {
    $cookie .= '; domain=' . $this->domain;
  }
  if ($this->path) {
    $cookie .= '; path=' . $this->path;
  }
  if ($this->secure) {
    $cookie .= '; secure';
  }
  if ($this->httponly) {
    $cookie .= '; httponly';
  }
  return $cookie;
}