public function setExpire($expire) : self
    {
        // convert expiration time to a Unix timestamp
        if ($expire instanceof \DateTime || $expire instanceof \DateTimeImmutable) {
            $expire = (int) $expire->format('U');
        } elseif (!is_numeric($expire) || !is_int($expire)) {
            throw new \InvalidArgumentException(sprintf(
                "The cookie expiration time is not valid with type '%s'",
                gettype($expire)
            ));
        } elseif ($expire > 0) {
            $expire = time() + $expire;
        }

        $this->expire = $expire;

        return $this;
    }