private function getUniqueKey(): string
    {
        do {
            try {
                $isDuplicate = null;
                $key = random_bytes($this->getOpt(self::OPT_SESSION_KEY_LENGTH));

                // Ask for duplicate key from storage
                $this->emit('duplicate-check', [$key, &$isDuplicate]);

            } catch (\Exception $e) {
                throw new SessionException($e->getMessage(), SessionException::ERR_RANDOM_BYTES);
            }
        } while (isset($this->SESSION[$key]) || $isDuplicate === true);

        return $key;
    }