I'm running PHP 8.1 and Laravel 10 and I have no problem with the sessions.
What error message do you get ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I upgraded my Project from laravel 6 to 9 without any problem. Now from Laravel 9 to 10 I have a Problem with the Session::put and get.
In Laravel 9 it was possible to use Session::put($e->getErrors()); and Session::get($errorKey)); So it was possible to use it with only a Key without a Value.
Why is this not possible with Laravel 10 and why is there no note about it in the Upgrade guide?
Im running PHP 8.1.
The Session::put() method has not changed between 9.x and 10.x. It is still possible to use it with only one parameter, but that parameter must then be an array. Note: an actual array, not just an object that is traversable like an array.
Your $results variable is a PendingDispatch object, not an array, so it won’t work. It doesn’t work in Laravel 9 either. The put() method uses is_array() to check if its first parameter ($key) is an array, and if it isn’t, it redefines $key to be an array with the original value of $key as the array key. Since an object is not a valid value for an array key, you get the error you’re seeing.
If you cast your object to an array, however, it should work:
if (Request::has('link')) {
Session::put((array) $results);
}
Please or to participate in this conversation.