public function generateId(): string
    {
        if ($this->saveHandler != null && method_exists($this->saveHandler, 'generateId')) {
            return $this->saveHandler->generateId($id);
        }

        $id = session_create_id();

        // hash by length
        if ($this->options['hash']) {
            switch ($this->options['hashLength']) {
                case 32: $id = hash('md5', $id); break;
                case 40: $id = hash('sha1', $id); break;
                case 64: $id = hash('sha256', $id); break;
                case 128: $id = hash('sha512', $id); break;
                default:
                    throw new SessionException("No valid 'hashLength' option given, only ".
                        "'32,40,64,128' are accepted");
            }
            $id = strtoupper($id);
        }

        return $id;
    }