you did not put any value?
$value = $request->session()->put('abc','my value');
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi guys , im running laravel 5.8. Im trying to set and get some session values but I got following message:
RuntimeException
Session store not set on request.
This is my controller:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class SessionController extends Controller
{
/**
* Show the profile for the given user.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function storeSessionData(Request $request) {
$value = $request->session()->put('key');
//
}
}
I did not tweak anything else.
Any ideas ? Leandro.
@leostereo it looks like it's not a web route (specified not in web.php), so the session was not initialized. Or StartSession middleware was not included for this route.
Check your app/Http/Kernel.php class
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
// ...
\Illuminate\Session\Middleware\StartSession::class, // <- this middleware is responsible for initializing sessions
// ...
],
'api' => [
'throttle:60,1',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
Please or to participate in this conversation.