Laravel - Session store not set on request
It sounds like you are trying to use the Laravel session, but it is not available in the current request.
It sounds like you are trying to use the Laravel session, but it is not available in the current request.
There are a few reasons why this might be happening:
- Make sure that the
webmiddleware group is applied to your route or route group. This will ensure that the session is available on the request. Routes defined inroutes/web.phpinclude it by default. For other route files, apply it explicitly:
Route::middleware('web')->get('/your-route', [YourController::class, 'method']);- If you are using the
sessionfacade or theAuthfacade and the session is not set, it could be because you are running an asynchronous job or a console command. In this case, the session is not available because it is only started in the HTTP kernel. You can verify the execution context with:
if (app()->runningInConsole()) {
// Session is not available here
}- If you are using a custom session driver (e.g.
database,memcached, etc.), make sure that you have correctly configured your session store and that it is working correctly. Verify your.envfile has the correctSESSION_DRIVERvalue, ensure the underlying service is running, and inspect the resolved configuration by runningphp artisan config:show session.
I hope this helps! Let me know if you have any other questions.