Laravel 4 - 反序列化():32 个字节的偏移量 0 处出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16863156/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 07:50:49  来源:igfitidea点击:

Laravel 4 - unserialize(): Error at offset 0 of 32 bytes

laravellaravel-4

提问by user2094178

When I install Laravel 4, I receive this error:

当我安装 Laravel 4 时,我收到此错误:

ErrorException
unserialize(): Error at offset 0 of 32 bytes

C:\xampp\htdocs\blog\laravel\bootstrap\compiled.php
return unserialize($this->stripPadding($this->mcryptDecrypt($value, $iv)));

If I modify return like this:

如果我像这样修改返回:

return unserialize(base64_decode($this->stripPadding($this->mcryptDecrypt($value, $iv))));

Then the error goes away. But of course every time I run composer update this change will be undone.

然后错误消失。但当然,每次我运行 composer update 时,此更改都会被撤消。

What could be the reason of this problem?

这个问题的原因是什么?

I appreciate any help.

我很感激任何帮助。

Update:This only happens when I use Auth::check().

更新:这仅在我使用 Auth::check() 时发生。

Update 2:Now it only works with base64_decode() removed. It's like if the xampp installation has become self-aware. Jesus!

更新 2:现在它只适用于 base64_decode() 删除。就像 xampp 安装已经成为自我意识一样。耶稣!

回答by Dwight

Refer to this issue: laravel/framework#1526

参考这个问题:laravel/framework#1526

A change in the encryption mechanism is the cause. My solution was to empty out the sessionsand viewsthat were cached in the storagefolder, then run php artisan key:generateand relaunch the server. I'm not sure which part of the process fixed the issue, but I haven't seen it since.

加密机制的变化是原因。我的解决方案是清空文件夹中缓存的sessions和,然后运行并重新启动服务器。我不确定该过程的哪一部分解决了该问题,但从那以后我就再也没有看到过。viewsstoragephp artisan key:generate

回答by monobloclimber

The command > php artisan cache:clear fixed the problem for me. I did not have to restart the server

命令> php artisan cache:clear 为我解决了这个问题。我不必重新启动服务器

回答by Jose Seie

You have to set a news Key, use the following command:

你必须设置一个新闻Key,使用以下命令:

php artisan key:generate

After that test again to run the Laravel Application

再次测试后运行 Laravel 应用程序

php artisan serve

回答by Half Crazed

Can you post what you're doing that causes this error? You shouldn't be modifying the core - because as you said, updates will overwrite it.

你能发布你正在做的导致这个错误的事情吗?您不应该修改核心 - 因为正如您所说,更新会覆盖它。