log-viewer icon indicating copy to clipboard operation
log-viewer copied to clipboard

unserialize(): Error at offset 0 of 81 bytes

Open irtzamazhar opened this issue 1 year ago • 3 comments

After setting up this package I faced unserialize(): Error at offset 0 of 81 bytes every time I reloaded my log-viewer route. It's working first time but if I refresh my page I get that error. After some googling, I got a solution and to regenerate APP_KEY will resolve it but still, if I refresh my page I get that issue.

image

irtzamazhar avatar Mar 07 '24 08:03 irtzamazhar

@irtzamazhar If you're not using Sanctum, you have to disable the EnsureFrontendRequestsAreStateful middleware in config/log-viewer.php. This middleware utilizes Sanctum's encrypt_cookies middleware if available; otherwise, it defaults to Laravel's EncryptCookies middleware. In Laravel's EncryptCookies middleware, serialize is false by default.

MujeebAnwar avatar Mar 08 '24 13:03 MujeebAnwar

what if i use sanctum , error will show again? @MujeebAnwar

MNhat0308 avatar Mar 09 '24 15:03 MNhat0308

In middle EncryptCookies file set protected static $serialize = false; to false and it work well

MNhat0308 avatar Mar 21 '24 09:03 MNhat0308

This seems to be an issue when using Sanctum, correct? Not sure why cookie serialization & deserialization fails, but it can be fixed by disabling serialization in EncryptCookies middleware, like mentioned above.

Closing the issue.

arukompas avatar Aug 16 '24 10:08 arukompas