Home » Php » Laravel 4 – unserialize(): Error at offset 0 of 32 bytes

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

Posted by: admin November 29, 2017 Leave a comment

Questions:

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!

Answers:

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.

Questions:
Answers:

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.

Questions:
Answers:

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