Understanding session management in Authelia: cookie configuration with name, domain, and validity, session storage in Redis for production scale, and cookie security aspects like Secure, SameSite, and HttpOnly so sessions are hard to hijack.

In episode 6, you wrote access rules: who can access which domain and with what level of authentication. But imagine if Authelia asked for a login again for every image file a page loads. That would feel like queuing behind security guards at every hallway door. The solution is the session: log in once, identity is remembered for a period of time.
A session is the lanyard card given after login. The cookie is the physical card your browser carries, and the session storage is the reception desk where the guard verifies the card's authenticity. In this episode you'll configure that lanyard card: its name, validity, where its data is stored, and how to make it hard to forge.
The session section controls cookie behavior and the domains Authelia can serve. The basic configuration:
session:
secret: "replace-with-a-long-64-character-secret"
name: "authelia_session"
same_site: "lax"
inactivity: "5m"
expiration: "1h"
remember_me: "1M"
cookies:
- domain: "example.com"
authelia_url: "https://auth.example.com"Each field has a specific role:
secret: the key used to encrypt session data stored in Redis. Must be strong and random, because anyone holding this secret can unpack the session contents.name: the cookie name used by the browser, default is authelia_session.inactivity: the session expires after the user is inactive for this duration. A short value like 5m closes the session automatically when you step away from your laptop.expiration: the maximum session age, regardless of how active the user is. This forces periodic re-authentication.remember_me: the session duration when the "remember me" box is checked, usually much longer than expiration.Tip
Think of inactivity like office lights that switch off automatically after no movement, and expiration like the obligation to replace your access card every month. Both close the gap when an account is no longer used but is still remembered by the system.
When a user checks "remember me", the cookie lasts for remember_me (for example 1M for one month) instead of the short expiration. That's convenient for personal devices, but dangerous when used on shared devices. A common policy in many organizations: enable remember_me only on networks you trust.
Authelia has two session storage providers:
session:
secret: "replace-with-a-long-64-character-secret"
redis:
host: "redis"
port: 6379
username: "authelia"
password: "redis-secret"
database_index: 0session:
secret: "replace-with-a-long-64-character-secret"
name: "authelia_session"Redis is strongly recommended for production. Because session secret data is encrypted with this key, make sure the secret is strong and identical across all Authelia instances sharing the same Redis. For high availability, Authelia also supports Redis Sentinel so failover happens automatically when the primary Redis server goes down.
The session cookie is the key that validates your identity on every request. If a cookie can be read or stolen, an attacker can impersonate you without knowing your password. Three defense mechanisms are available to a cookie:
document.cookie. Authelia enables this automatically.lax value (default) is a good balance between security and functionality.Warning
Don't lower same_site: "lax" to none without a strong reason. The none value requires a pure HTTPS connection and expands the CSRF attack surface. If a service has cookie problems, check the proxy configuration and headers first before loosening SameSite.
Session hijacking isn't only prevented from the cookie side: with Redis as storage, you can also use Redis Sentinel, and set database_index to separate session data from other application data on the same Redis. The fewer parties that can access the session storage, the harder a session is to forge.
Cookies are only sent to domains matching their domain attribute. Authelia handles this via the cookies list where each entry defines a protected SSO domain along with its portal URL:
session:
cookies:
- domain: "example.com"
authelia_url: "https://auth.example.com"
default_redirection_url: "https://app.example.com"
- domain: "example.org"
authelia_url: "https://auth.example.org"
default_redirection_url: "https://app.example.org"A few important rules here:
example.com domain, the cookie applies to all its subdomains — app.example.com, admin.example.com, and so on. This is what makes SSO across services on one main domain feel seamless.example.com and sub.example.com domains can't be registered together because they collide.example.com and example.net. For that scenario you need the OpenID Connect route, which will be covered in the identity phase in episode 17.Tip
Get into the habit of testing in the same browser with developer tools. Inspect the authelia_session cookie value, note its HttpOnly, Secure, and SameSite attributes, then simulate an inactivity period to see when the session expires. Direct observation is more convincing than just reading logs.
Key points of this episode:
inactivity closes idle sessions, expiration limits the maximum age, remember_me extends it explicitly.Sessions are temporary: when Authelia restarts or a session expires, everything is gone. But there's data that must survive a lifetime — TOTP secrets, WebAuthn credentials, even Duo device IDs. In episode 8, you'll get to know the storage backend: the permanent data database choices, their configuration, schema migrations, and backup strategies that prevent users from losing their MFA devices.