W3docs

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:

  1. Make sure that the web middleware group is applied to your route or route group. This will ensure that the session is available on the request. Routes defined in routes/web.php include it by default. For other route files, apply it explicitly:
Route::middleware('web')->get('/your-route', [YourController::class, 'method']);
  1. If you are using the session facade or the Auth facade 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
}
  1. 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 .env file has the correct SESSION_DRIVER value, ensure the underlying service is running, and inspect the resolved configuration by running php artisan config:show session.

I hope this helps! Let me know if you have any other questions.