You are here

private function RequestDataCollector::getCookieHeader in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/DataCollector/RequestDataCollector.php \Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::getCookieHeader()
1 call to RequestDataCollector::getCookieHeader()
RequestDataCollector::collect in vendor/symfony/http-kernel/DataCollector/RequestDataCollector.php
Collects data for the given Request and Response.

File

vendor/symfony/http-kernel/DataCollector/RequestDataCollector.php, line 306

Class

RequestDataCollector
RequestDataCollector.

Namespace

Symfony\Component\HttpKernel\DataCollector

Code

private function getCookieHeader($name, $value, $expires, $path, $domain, $secure, $httponly) {
  $cookie = sprintf('%s=%s', $name, urlencode($value));
  if (0 !== $expires) {
    if (is_numeric($expires)) {
      $expires = (int) $expires;
    }
    elseif ($expires instanceof \DateTime) {
      $expires = $expires
        ->getTimestamp();
    }
    else {
      $tmp = strtotime($expires);
      if (false === $tmp || -1 == $tmp) {
        throw new \InvalidArgumentException(sprintf('The "expires" cookie parameter is not valid (%s).', $expires));
      }
      $expires = $tmp;
    }
    $cookie .= '; expires=' . str_replace('+0000', '', \DateTime::createFromFormat('U', $expires, new \DateTimeZone('GMT'))
      ->format('D, d-M-Y H:i:s T'));
  }
  if ($domain) {
    $cookie .= '; domain=' . $domain;
  }
  $cookie .= '; path=' . $path;
  if ($secure) {
    $cookie .= '; secure';
  }
  if ($httponly) {
    $cookie .= '; httponly';
  }
  return $cookie;
}