public function createHeader(): string
    {
        $header = [rawurlencode($this->name) . '=' . rawurlencode((string)$this->value)];

        if ($this->lifetime !== null) {
            $header[] = 'Expires=' . gmdate(\DateTime::COOKIE, $this->getExpires());
            $header[] = 'Max-Age=' . $this->lifetime;
        }

        if (!empty($this->path)) {
            $header[] = 'Path=' . $this->path;
        }

        if (!empty($this->domain)) {
            $header[] = 'Domain=' . $this->domain;
        }

        if ($this->secure) {
            $header[] = 'Secure';
        }

        if ($this->httpOnly) {
            $header[] = 'HttpOnly';
        }

        return join('; ', $header);
    }