better-auth · Better Auth Docs
Session Management | Better Auth
Explains how Better Auth handles cookie-based session management, including session table schema, expiration logic, and configuration for expiresIn and updateAge parameters.
Derived skill
Files assembled from official documentation
Viewing SKILL.md
Session Management | Better Auth
Explains how Better Auth handles cookie-based session management, including session table schema, expiration logic, and configuration for expiresIn and updateAge parameters.
When To Use
Use when configuring session expiration durations, setting up automatic session refresh intervals, or designing the database schema for user sessions.
Reference Files
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/session-management-better-auth-workflow-guide.md | A conceptual guide explaining session expiration, freshness, cookie caching, and stateless session strategies in Better Auth. | Questions about a conceptual guide explaining session expiration, freshness, cookie caching, and stateless session strategies in Bett... |
examples/session-management-better-auth-better-auth-session-configuration-options.text | A configuration object demonstrating how to set expiresIn and updateAge properties within the better-auth session settings. | Exact payloads, commands, or snippets shown in A configuration object demonstrating how to set expiresIn and updateAge properties within the better-auth session set... |
examples/session-management-better-auth-better-auth-session-management-config.text | A configuration example demonstrating how to manage session settings, such as disabling session refresh, using the better-auth library. | Exact payloads, commands, or snippets shown in A configuration example demonstrating how to manage session settings, such as disabling session refresh, using the be... |
examples/session-management-better-auth-better-auth-session-management-configurat.text | A code example demonstrating how to configure session management options such as deferSessionRefresh within the better-auth initialization object. | Exact payloads, commands, or snippets shown in A code example demonstrating how to configure session management options such as deferSessionRefresh within the bette... |
examples/session-management-better-auth-better-auth-session-fresh-age-configurati.text | A TypeScript code snippet demonstrating how to configure the session freshAge property within the better-auth initialization object. | Exact payloads, commands, or snippets shown in A TypeScript code snippet demonstrating how to configure the session freshAge property within the better-auth initial... |
examples/session-management-better-auth-better-auth-session-config-fresh-age.text | A configuration example demonstrating how to disable session freshness checks using the freshAge property in better-auth. | Exact payloads, commands, or snippets shown in A configuration example demonstrating how to disable session freshness checks using the freshAge property in better-a... |
examples/session-management-better-auth-better-auth-session-get-session-client.text | A TypeScript code snippet demonstrating how to use the authClient to retrieve the current user session. | Exact payloads, commands, or snippets shown in A TypeScript code snippet demonstrating how to use the authClient to retrieve the current user session. |
examples/session-management-better-auth-better-auth-session-management-client-use.text | A TypeScript code example demonstrating how to use the authClient.useSession hook to retrieve the current user session. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to use the authClient.useSession hook to retrieve the current user session. |
examples/session-management-better-auth-better-auth-session-management-list-sessi.text | A TypeScript code snippet demonstrating how to use the better-auth client to list active user sessions. | Exact payloads, commands, or snippets shown in A TypeScript code snippet demonstrating how to use the better-auth client to list active user sessions. |
examples/session-management-better-auth-better-auth-session-management-revoke-ses.text | A code example demonstrating how to use the authClient to revoke a specific session using a session token. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the authClient to revoke a specific session using a session token. |
examples/session-management-better-auth-better-auth-session-management-revoke-oth.text | A code example demonstrating how to use the better-auth client to revoke all other active user sessions. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the better-auth client to revoke all other active user sessions. |
examples/session-management-better-auth-better-auth-session-management-revoke-ses-2.text | A code example demonstrating how to use the authClient to revoke user sessions in better-auth. | Exact payloads, commands, or snippets shown in A code example demonstrating how to use the authClient to revoke user sessions in better-auth. |
examples/session-management-better-auth-better-auth-session-update-client.text | A TypeScript code example demonstrating how to use the authClient to update session data such as theme and language. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to use the authClient to update session data such as theme and language. |
examples/session-management-better-auth-better-auth-update-session-api.text | An example demonstrating how to use the updateSession API method to modify session properties like theme using the better-auth client. | Exact payloads, commands, or snippets shown in An example demonstrating how to use the updateSession API method to modify session properties like theme using the be... |
examples/session-management-better-auth-better-auth-session-management-change-pas.text | A TypeScript code example demonstrating how to use the authClient to change a user password and optionally revoke other active sessions. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to use the authClient to change a user password and optionally revoke oth... |
examples/session-management-better-auth-better-auth-session-cookie-cache-configur.text | A configuration example demonstrating how to enable and set the maxAge for cookie caching within the better-auth session object. | Exact payloads, commands, or snippets shown in A configuration example demonstrating how to enable and set the maxAge for cookie caching within the better-auth sess... |
examples/session-management-better-auth-better-auth-session-management-configurat-2.text | A configuration example demonstrating session management settings including cookie cache, maxAge, and session strategies like compact, jwt, or jwe. | Exact payloads, commands, or snippets shown in A configuration example demonstrating session management settings including cookie cache, maxAge, and session strateg... |
examples/session-management-better-auth-better-auth-session-get-session-client-2.text | A TypeScript code example demonstrating how to use the authClient to retrieve the current session using the getSession method. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to use the authClient to retrieve the current session using the getSessio... |
examples/session-management-better-auth-better-auth-session-get-session-api.text | An example demonstrating how to use the getSession API method to retrieve session data using headers and query parameters. | Exact payloads, commands, or snippets shown in An example demonstrating how to use the getSession API method to retrieve session data using headers and query parame... |
examples/session-management-better-auth-better-auth-session-management-secondary-.text | A code example demonstrating how to implement the secondaryStorage option within the betterAuth configuration for custom session management. | Exact payloads, commands, or snippets shown in A code example demonstrating how to implement the secondaryStorage option within the betterAuth configuration for cus... |
examples/session-management-better-auth-better-auth-session-management-configurat-3.text | A configuration example demonstrating how to implement session management and secondary storage within the better-auth instance. | Exact payloads, commands, or snippets shown in A configuration example demonstrating how to implement session management and secondary storage within the better-aut... |
examples/session-management-better-auth-better-auth-session-management-secondary--2.text | A configuration example demonstrating how to implement secondary storage and database session preservation within the better-auth client. | Exact payloads, commands, or snippets shown in A configuration example demonstrating how to implement secondary storage and database session preservation within the... |
examples/session-management-better-auth-better-auth-session-management-configurat-4.text | A TypeScript code example demonstrating the basic configuration of the better-auth instance for session management. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating the basic configuration of the better-auth instance for session management. |
examples/session-management-better-auth-better-auth-session-management-configurat-5.text | A configuration object demonstrating session management settings including cookie cache, strategy, and refresh options for better-auth. | Exact payloads, commands, or snippets shown in A configuration object demonstrating session management settings including cookie cache, strategy, and refresh option... |
examples/session-management-better-auth-better-auth-session-cookie-cache-configur-2.text | A configuration object demonstrating how to enable and tune cookie cache settings for session management in better-auth. | Exact payloads, commands, or snippets shown in A configuration object demonstrating how to enable and tune cookie cache settings for session management in better-auth. |
examples/session-management-better-auth-better-auth-session-management-cookie-cac.text | A configuration example demonstrating how to use the cookieCache property within the better-auth session object to manage session invalidation via versioning. | Exact payloads, commands, or snippets shown in A configuration example demonstrating how to use the cookieCache property within the better-auth session object to ma... |
examples/session-management-better-auth-better-auth-session-management-redis-seco.text | A configuration example demonstrating how to implement secondary storage using Redis for better-auth session management. | Exact payloads, commands, or snippets shown in A configuration example demonstrating how to implement secondary storage using Redis for better-auth session management. |
examples/session-management-better-auth-better-auth-custom-session-plugin-typescr.text | A TypeScript code example demonstrating how to use the customSession plugin to extend user and session data in better-auth. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to use the customSession plugin to extend user and session data in better... |
examples/session-management-better-auth-better-auth-custom-session-client-plugin.text | A TypeScript code example demonstrating how to implement a custom session client plugin using the better-auth client. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to implement a custom session client plugin using the better-auth client. |
examples/session-management-better-auth-better-auth-custom-session-plugin-configu.text | A TypeScript code example demonstrating how to implement a custom session plugin using the better-auth configuration object. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to implement a custom session plugin using the better-auth configuration... |
examples/session-management-better-auth-better-auth-custom-session-plugin-impleme.text | A TypeScript code example demonstrating how to implement a custom session plugin using the betterAuth configuration object. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to implement a custom session plugin using the betterAuth configuration o... |
What This Skill Covers
- Learn about session management in Better Auth, including session expiration, freshness, cookie caching strategies, secondary storage, stateless sessions, and...
- Main sections:
Session table,Session Expiration,Disable Session Refresh,Defer Session Refresh,Session Freshness.
Workflow
- Open the most relevant file under
docs/for the exact documented workflow and wording. - Open
schemas/files for exact structured contracts. - Open
examples/files for concrete requests, commands, snippets, and manifests. - Do not add behavior or configuration that is not present in the attached source files.
Canonical source: https://www.better-auth.com/docs/concepts/session-management