Overview
TheSessionConfig interface defines how sessions are created, stored, and managed in Arraf Auth.
Fields
The session storage strategy.
"jwt": Sessions are stored as signed JWT tokens in cookies. Faster and stateless, but cannot be invalidated server-side until expiration."database": Sessions are stored in the database with a session token in the cookie. Can be invalidated immediately but requires database queries.
Session expiration time as a human-readable string. Supports units:
s (seconds), m (minutes), h (hours), d (days).Sessions are automatically renewed on each request, extending the expiration time.
The name of the cookie used to store the session token.
Change this if you have multiple Arraf Auth instances on the same domain to avoid conflicts.
Additional cookie configuration options for security and cross-domain support.
When
true, the cookie is only sent over HTTPS connections. Automatically set to false for localhost.Controls when cookies are sent in cross-site requests.
"strict": Cookie is never sent in cross-site requests. Most secure but may break OAuth flows."lax": Cookie is sent on top-level navigation (recommended for most apps)."none": Cookie is always sent. Requiressecure: true.
When
true, the cookie is inaccessible to JavaScript’s document.cookie API. Protects against XSS attacks.The domain where the cookie is valid. Useful for sharing sessions across subdomains.
Omit this field to restrict cookies to the current domain only.
Default Configuration
If noSessionConfig is provided, Arraf Auth uses these defaults:
Usage Examples
Database Strategy with Long Expiration
Cross-Subdomain Sessions
Development Configuration
Security Best Practices
Recommended production settings:
- Use
strategy: "database"for immediate session revocation - Set
secure: trueto enforce HTTPS - Keep
httpOnly: trueto prevent XSS attacks - Use
sameSite: "lax"for most applications