public function __toString()
{
if ($this->value === false) {
$value = 0;
} else {
$value = $this->value;
}
$cookiePair = sprintf('%s=%s', $this->name, urlencode($value));
$attributes = '';
if ($this->expiresTimestamp !== 0) {
$attributes .= '; Expires=' . gmdate('D, d-M-Y H:i:s T', $this->expiresTimestamp);
}
if ($this->maximumAge !== null && $this->maximumAge > 0) {
$attributes .= '; Max-Age=' . $this->maximumAge;
}
if ($this->domain !== null) {
$attributes .= '; Domain=' . $this->domain;
}
$attributes .= '; Path=' . $this->path;
if ($this->secure) {
$attributes .= '; Secure';
}
if ($this->httpOnly) {
$attributes .= '; HttpOnly';
}
return $cookiePair . $attributes;
}