public function regenerateId($deleteOldSession = false)
    {
        if (headers_sent() || !$this->id) {
            return false;
        }
        $oldId = $this->id;
        $this->id = IdGenerator::generateSessionId($this->idLength);
        $this->setCookie($this->name, $this->id);
        if ($oldId && $deleteOldSession) {
            $this->handler->destroy($oldId);
        }
        return true;
    }