protected function prepareForUnserialization(string $data = null) : string
    {
        if ($data === null) {
            return '';
        }

        if ($this->usesEncryption) {
            if ($this->encrypter === null) {
                throw new LogicException('Encrypter not set on session handler');
            }

            try {
                return $this->encrypter->decrypt($data);
            } catch (SessionEncryptionException $ex) {
                return serialize([]);
            }
        } else {
            return $data;
        }
    }