{"record":{"id":"bb923423e7a75ce2","repo":"withastro/astro","slug":"astro-session-was-accessed-but-no-session-storag","errorCode":null,"errorMessage":"`Astro.session` was accessed but no session storage is configured. Either configure the storage manually or use an adapter that provides session storage. For more information, see https://docs.astro.build/en/guides/sessions/","messagePattern":"`Astro\\.session` was accessed but no session storage is configured\\. Either configure the storage manually or use an adapter that provides session storage\\. For more information, see https://docs\\.astro\\.build/en/guides/sessions/","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/astro/src/core/fetch/fetch-state.ts","lineNumber":907,"sourceCode":"\t\tif (this.#providers) {\n\t\t\tfor (const key of this.#providers.keys()) {\n\t\t\t\tObject.defineProperty(target, key, {\n\t\t\t\t\tget: () => state.resolve(key),\n\t\t\t\t\tenumerable: true,\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\t// Ensure `session` is always a defined property even when the\n\t\t// sessions handler is not part of the pipeline. Warns once on\n\t\t// access so users know they need to configure session storage.\n\t\tif (!this.#providers?.has('session')) {\n\t\t\tlet warned = false;\n\t\t\tObject.defineProperty(target, 'session', {\n\t\t\t\tget() {\n\t\t\t\t\tif (!warned) {\n\t\t\t\t\t\twarned = true;\n\t\t\t\t\t\tstate.logger.warn(\n\t\t\t\t\t\t\t'session',\n\t\t\t\t\t\t\t'`Astro.session` was accessed but no session storage is configured. ' +\n\t\t\t\t\t\t\t\t'Either configure the storage manually or use an adapter that provides session storage. ' +\n\t\t\t\t\t\t\t\t'For more information, see https://docs.astro.build/en/guides/sessions/',\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn undefined;\n\t\t\t\t},\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Resolves the route to use for this request and stores it on\n\t * `this.routeData`. If the adapter (or the dev server) provided a\n\t * `routeData` via render options it's already set and this is a","sourceCodeStart":889,"sourceCodeEnd":925,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/astro/src/core/fetch/fetch-state.ts#L889-L925","documentation":"Astro defines `Astro.session` on the request context even when no session storage is wired into the pipeline; in that case it installs a getter that logs this warning once (domain 'session') and returns undefined. It exists so code touching `Astro.session` degrades visibly instead of throwing, pointing you to either configure storage or use an adapter that provides it.","triggerScenarios":"Reading `Astro.session` in a page, layout, middleware, or endpoint while the pipeline has no 'session' provider: no top-level `session` config in astro.config and an adapter that does not supply session storage (or no adapter at all).","commonSituations":"Running output 'static' with no adapter while middleware touches Astro.session; deploying with an adapter that lacks session support; starting to use sessions after an Astro upgrade before configuring a driver.","solutions":["Add a top-level `session` config with a driver, e.g. session: { driver: { entrypoint: 'astro/session/drivers/file', config: { path: './.session' } } }","Switch to an adapter that provides session storage out of the box (for example @astrojs/node)","If sessions are not actually needed, remove the code reading Astro.session — it will only ever be undefined"],"exampleFix":"// astro.config.mjs — before\nexport default defineConfig({ output: 'server' }); // no session storage configured\n\n// after\nexport default defineConfig({\n  output: 'server',\n  session: {\n    driver: {\n      entrypoint: 'astro/session/drivers/file',\n      config: { path: './.session' },\n    },\n  },\n});","handlingStrategy":"validation","validationCode":"const session = Astro.session;\nif (session === undefined) {\n  // no storage configured — take a non-session code path\n} else {\n  const user = await session.get('user');\n}","typeGuard":"function hasSession(astro: { session: unknown }): boolean {\n  return astro.session !== undefined;\n}","tryCatchPattern":null,"preventionTips":["Configure a session driver in astro.config before writing session code","Use an adapter that declares session storage support","Gate session-dependent logic behind a defined-check so static builds never touch Astro.session"],"tags":["session","config","adapter","middleware"],"backgroundTag":"missing-session-storage","analyzedSha":"e294953aa8aadd98d5be92e60a03037b05dbdfd4","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}