{"record":{"id":"0cf19ebbd623362b","repo":"laravel/framework","slug":"session-store-requires-session-manager-to-be-avail","errorCode":null,"errorMessage":"Session store requires session manager to be available in container.","messagePattern":"Session store requires session manager to be available in container\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Cache/CacheManager.php","lineNumber":405,"sourceCode":"                $config['key'] ?? '_cache',\n            ),\n            $config\n        );\n    }\n\n    /**\n     * Get the session store implementation.\n     *\n     * @return \\Illuminate\\Contracts\\Session\\Session\n     *\n     * @throws \\InvalidArgumentException\n     */\n    protected function getSession()\n    {\n        $session = $this->app['session'] ?? null;\n\n        if (! $session) {\n            throw new InvalidArgumentException('Session store requires session manager to be available in container.');\n        }\n\n        return $session;\n    }\n\n    /**\n     * Create a new cache repository with the given implementation.\n     *\n     * @param  \\Illuminate\\Contracts\\Cache\\Store  $store\n     * @param  array  $config\n     * @return \\Illuminate\\Cache\\Repository\n     */\n    public function repository(Store $store, array $config = [])\n    {\n        return tap(new Repository($store, Arr::only($config, ['store'])), function ($repository) use ($config) {\n            if ($config['events'] ?? true) {\n                $this->setEventDispatcher($repository);\n            }","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Cache/CacheManager.php#L387-L423","documentation":"CacheManager::getSession backs the 'session' cache driver — it returns the bound session manager from the container (app('session')). When the session service provider has not been registered (e.g., using illuminate/cache standalone, or in an API-only app with sessions disabled), the 'session' binding is absent and the cache driver cannot be constructed.","triggerScenarios":"Configuring a cache store with 'driver' => 'session' in config/cache.php while Illuminate\\Session\\SessionServiceProvider is not registered. Calling Cache::store('session') in a stateless API stack (Laravel Sanctum without web middleware) where sessions were intentionally removed.","commonSituations":"API-only Laravel app that removed SessionServiceProvider to avoid session overhead but still has a stale 'session' cache store. Standalone illuminate/cache usage in a non-Laravel script. Custom application bootstrap that omits session provider.","solutions":["Register Illuminate\\Session\\SessionServiceProvider in config/app.php (or bootstrap/app.php providers in Laravel 11+).","If sessions are intentionally disabled, switch the cache store's 'driver' to a supported alternative (array, file, redis) and remove the 'session' cache store entry.","Ensure the session middleware is on the route stack for the request that initializes the session-bound cache."],"exampleFix":"// before - bootstrap/app.php (Laravel 11+) without session provider, but config/cache.php declares:\n'stores' => [\n    'session-cache' => ['driver' => 'session'],\n],\n\n// after - register the provider\n->withProviders([\n    Illuminate\\Session\\SessionServiceProvider::class,\n])\n// OR remove the 'session' cache store entry if sessions are unused","handlingStrategy":"validation","validationCode":"// Validate the session binding exists before using a session cache driver\nif (config('cache.stores.session.driver') === 'session' && ! app()->bound('session')) {\n    throw new \\RuntimeException('Session cache driver requires SessionServiceProvider to be registered.');\n}","typeGuard":"function sessionManagerIsBound(): bool\n{\n    return app()->bound('session');\n}","tryCatchPattern":null,"preventionTips":["Audit service providers when removing sessions to also remove the 'session' cache store entry.","In API-only apps, default the cache driver to 'file' or 'redis', never 'session'.","Add a boot-time assertion that any store with driver=session has the session manager bound."],"tags":["cache","session","service-provider","container"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}