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

不羁岁月 提交于 2019-12-06 01:59:44

问题


When I install Laravel 4, I receive this error:

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.

What could be the reason of this problem?

I appreciate any help.

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

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


回答1:


Refer to this issue: laravel/framework#1526

A change in the encryption mechanism is the cause. My solution was to empty out the sessions and views that were cached in the storage folder, then run php artisan key:generate and relaunch the server. I'm not sure which part of the process fixed the issue, but I haven't seen it since.




回答2:


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




回答3:


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.




回答4:


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

php artisan key:generate

After that test again to run the Laravel Application

php artisan serve


来源:https://stackoverflow.com/questions/16863156/laravel-4-unserialize-error-at-offset-0-of-32-bytes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!