Server-side sessions and session lifetime in Apache Superset

Server-side sessions make logout end a session on the server, not just in the browser. This page covers the backend choice, lifetime and cookie flags, and the SameSite trade-off for embedding.

On this page

Why Superset sessions need a server-side backend

A production Superset must end a session when a user logs out and expire sessions that sit idle, and the default cookie-based session does not reliably do either. In Flask-based applications such as Superset, the session payload is held in a signed cookie in the user's browser. The server can verify the signature, but it has no record of which sessions are still valid. Once a cookie has been copied, left on a shared workstation, or captured from a compromised device, the server has no list of sessions to revoke, so logout clears the browser copy but cannot invalidate the token itself. Confirm how your installed Superset version and its Flask session settings handle this before you rely on logout as a control.

A server-side backend changes the trust point. The browser holds only an opaque session identifier, and the session data lives in Redis or the metadata database. Logout then deletes the server-side record, and idle or absolute lifetimes can be enforced where the server controls them. Teams usually need this when shared kiosks or lab workstations are in use, when an audit finding asks for demonstrable session termination, or when logout must propagate from an identity provider. Superset's architecture documentation describes Redis as the common choice for the caching layer, so check whether your deployment already runs Redis before you choose a backend.

This is a configuration and testing task, not a product change. You will select the session backend, set lifetime and cookie flags, and then prove the behavior with a logout test, a replayed-cookie test and an idle-timeout test on staging. The engineering effort depends mainly on whether Redis is already operated and whether your identity provider sends back-channel logout. Ask your team or a partner to document the chosen backend, the lifetime values and the test evidence before go-live.

Choosing a Redis or database session backend

The right backend usually follows from what your team already runs. Superset's architecture has four parts: the Flask and React application, a metadata database, an optional caching layer and optional Celery workers. If your deployment already has the caching layer for async queries, alerts, reports or thumbnails, Redis is already in the stack and adding session storage to it adds no new service. If the team wants fewer moving parts, the metadata database can hold sessions without another component. Both options add load to a service you must size and monitor, so the choice should be made against your existing service inventory rather than a general preference.

  • Redis when the cache already runs: Session reads happen on every authenticated request, so the Redis instance needs capacity and monitoring that match its current duties.
  • Database when the stack should stay small: Sessions share the metadata database's backups, access controls and upgrade windows, and their write load adds to that database.
  • Ownership of the service: Confirm which team gets paged if the session store fails and whether that team already runs the chosen service.
  • Supported interfaces: Confirm the session interface names and related settings for your Superset version in the configuration documentation before writing configuration.
  • Environment parity: Use the same backend in staging and production so that logout and expiry tests reflect production behavior.

Check which services already run in production and who operates each one before you pick a backend.

Session settings and when each fits

This table compares the session decisions that control how long a Superset login stays valid and where that state lives. Read each row for the typical direction, the user effect and the risk of leaving the setting at its default. Confirm every default value in the Superset configuration documentation for your exact version before you change anything.

SettingTypical directionEffect on usersRisk if left at default
Session backendServer-side store such as Redis or the metadata database, so the server holds session stateLogout invalidates the session everywhere, and sessions survive browser restarts only as the backend allowsClient cookies carry session state, so a copied cookie can stay usable until it expires
Session lifetimeSet a bounded maximum that fits your access review cycle, and confirm the unit and default in the configuration docsShorter lifetimes require more frequent sign-in, which matters most for shared workstationsA long lifetime widens the window in which a stolen session works
Idle timeoutShorter idle timeout for analyst and admin roles, longer for dashboard viewers on kiosksUsers who step away are signed out, and unsaved SQL Lab work may be lostUnattended sessions stay open on shared machines
Absolute timeoutHard cap on total session age, independent of activityUsers re-authenticate on a fixed schedule even while activeContinuous activity can keep a session alive indefinitely
Cookie Secure flagEnabled so the browser sends the cookie only over HTTPSNo visible change when TLS terminates correctly at the proxyCookie can travel over plain HTTP if a redirect or mixed content exposes it
Cookie HttpOnly flagEnabled so scripts cannot read the session cookieNo visible change for normal useA script injection could read and exfiltrate the session cookie
SameSite valueStrict or Lax for the main UI, with a deliberate exception only for embedded dashboards that need cross-site cookiesStrict can break sign-in flows that redirect from an identity provider, and cross-site iframes may lose the sessionDefault values may allow cross-site requests to carry the session in some browsers
Refresh behaviorRefresh on activity only within the idle window, and never extend past the absolute capActive users stay signed in during a working session without manual sign-inRefresh that extends sessions without limit makes the lifetime setting meaningless

Setting up a server-side session backend

This sequence moves Superset from browser cookie sessions to a Redis or database session store, so that logout and idle expiry are enforced on the server and you can prove it before the change reaches production.

  1. Confirm metadata database and cache versions

    Before changing anything, check the PostgreSQL or MySQL version of your metadata database against the supported range in the Superset configuration documentation, which lists PostgreSQL 10 to 17 and MySQL 5.7 and 8.x. Confirm the Redis version your platform team runs and that your Superset release is the one you intend to operate. Record the results in the change ticket. The step is done when the versions are written down and every component is inside a supported range. If a version falls outside the list, stop and confirm the support position with the vendor or project before continuing.

  2. Back up the metadata database

    Take a full backup of the metadata database, which holds users, roles, and the session-related state you are about to change, and confirm it can be restored. Follow the backup guidance in the Superset upgrade documentation, which says to back up the metadata database before running database changes. Store a copy outside the host that runs Superset. The step is done when a test restore to a scratch instance succeeds and the restore time is recorded for your runbook.

  3. Choose and provision the session backend

    Decide between a Redis session store and a database-backed store. Redis suits deployments that already run it for caching, alerts and async queries, since the architecture documentation describes the caching layer as a common Redis and Celery pairing. A database store adds load to the metadata database but needs no extra service. Provision the chosen backend in a private network segment reachable only by the Superset web and worker hosts, with authentication enabled. The step is done when the web hosts can connect to the backend and an unauthenticated connection is refused.

  4. Set session configuration in superset_config.py

    Edit superset_config.py to point the session interface at the chosen backend and to set the session lifetime, cookie name, and cookie flags. Set Secure, HttpOnly, and an explicit SameSite value, and keep the SECRET_KEY unchanged so existing configuration still loads. Document the SameSite choice, because stricter values can break iframe embedding. Apply the same file to every web and worker host. The step is done when the file passes a syntax check on a staging host and the values match the change record.

  5. Test the change in staging first

    Apply the configuration to a staging copy that uses the same Superset version, database engine, and identity provider as production. Follow the upgrade guidance and test there before production, and keep a rollback copy of the previous configuration. Run the checks in the following steps against staging. The step is done when staging behaves as expected through a full login, dashboard load, and logout cycle, and the results are recorded.

  6. Restart all web and worker processes

    Restart every Superset web process and every Celery worker and beat process so that none keeps the old session settings in memory. Partial restarts leave some sessions on the old behavior, which makes test results misleading. Confirm each process started without errors in its logs and that the backend connection is established. The step is done when every process reports the new configuration and no host is still running the previous version of the file.

  7. Verify logout, cookie flags, and idle expiry

    Sign in, copy the session cookie, log out, then replay the copied cookie in a new request. The server must reject it, and the matching record should be absent from the Redis or database store. In the browser developer tools, confirm that the cookie carries the Secure, HttpOnly, and SameSite attributes you set. Leave a test session idle past the configured lifetime and confirm the next request requires sign-in. Repeat the checks for each identity provider path. The step is done when all three checks pass in production and the evidence is saved to the change record.

The SameSite trade-off when Superset is embedded in iframes

Tightening the session cookie's SameSite value is the change most likely to break embedded dashboards, and loosening it is the change most likely to widen cross-site request exposure. The decision depends on how the iframe authenticates. A guest token flow gives the embedded viewer a short-lived token issued by your application, so the Superset session cookie may not be needed for the embedded view at all. A flow where the iframe relies on a logged-in Superset session depends on the browser sending that cookie inside a cross-site frame, which a stricter SameSite setting can prevent.

With SameSite=Lax or Strict, the browser withholds the cookie from many cross-site iframe requests, so a user who is logged in to Superset in a top-level tab may see the embedded dashboard fail to load or prompt for sign-in. Relaxing the value to None (which requires the Secure flag) makes the cookie available in third-party frames, but it also means that other sites can cause the browser to send authenticated requests to Superset. Your team should weigh that against the CSRF protections that Superset and Flask-AppBuilder already apply to state-changing requests, and confirm in your own environment which endpoints the embedded views call. Ask your Superset and embedding contacts to document the exact cookie attributes each path requires before you change any of them.

Test both paths before you change the cookie policy. For the guest token path, confirm that a fresh browser with no Superset session can load the embedded dashboard, and that tokens expire as configured. For the logged-in path, test from a page on a different site, in each browser your users run, and check that the dashboard renders and that logout still ends the embedded session. Embedding specifics such as the SDK, guest token handling, allowed domains and browser security settings are covered in the Apache Superset embedded analytics content group, so keep those decisions with the embedding design rather than setting cookie flags in isolation.

Security and operational considerations for session stores

A server-side session store holds the authenticated state for every signed-in user, so it becomes a target in its own right. The cards below cover the controls that keep that store safe, tidy and auditable once logout and lifetime rules depend on it.

Protect the store from unauthorized reads

Anyone who can read the session backend can take over a live session, so treat the Redis instance or the metadata database table as a credential-bearing system. Restrict network access to the Superset web and worker hosts, require authentication on Redis, and limit database grants on the session table to the Superset service account. Confirm who on your platform team can run commands against the store in production.

Encrypt traffic to the store

Session records travel between the Superset web processes and Redis or the database on every request. Where that traffic crosses a host or network boundary, enable TLS on the connection and confirm the client in your Superset configuration validates the server certificate. Ask your platform team whether the Redis or database service supports client certificates and whether your policy requires them.

Clean up expired session records

Session tables and Redis keys grow with every login, and expired rows are not always removed automatically. Decide who owns the cleanup job, how often it runs, and how it matches the session lifetime you configured. Check the database size and key count after a few weeks of normal use so you know whether the cleanup works before the store becomes a capacity problem.

Coordinate logout with the identity provider

Ending a Superset session does not automatically end the session at your identity provider, so a user who signs out of Superset may still be signed in elsewhere. Decide whether your rollout needs single logout across the IdP and Superset, and test it with a real browser. Confirm how your chosen IdP handles back-channel logout and whether Superset's login integration supports it in your version.

Handle the secret key with the store

Session cookies are signed with the SECRET_KEY, so the key that protects the store also protects every session it issues. Keep the key out of source control, give each environment its own value, and plan rotation with PREVIOUS_SECRET_KEY before you need it. Work through the SECRET_KEY rotation topic so key changes and session invalidation are planned together.

Log session events for audit

Auditors ask who signed in, when sessions ended and whether logout actually revoked access, so the session backend needs a record of those events. Decide which events you log (login, logout, timeout, forced revocation), where those logs are stored, and how long they are kept. Confirm with your compliance lead which retention period applies and test that a sample logout appears in the log.

Questions teams ask before changing Superset sessions

How much effort does moving Superset to server-side sessions take?

The effort depends mostly on the session backend, the number of Superset instances, and how login is wired to your identity provider. Moving to a Redis or database session backend is a configuration change in superset_config.py, but it also needs a shared store that every web instance can reach, and a plan for the sessions that already exist. Effort rises when you run several web nodes behind a load balancer, when login goes through an OAuth2 or LDAP provider that has its own session lifetime, or when embedded dashboards depend on cookie behavior. Ask the partner to break the estimate into backend setup, configuration, IdP alignment, embedding checks and testing, so you can see which parts your team already covers.

Can our own team change Superset sessions without a partner?

A capable team can make this change without outside help if it has the right skills. The work touches Flask-based configuration, the Superset metadata and cache infrastructure, Redis or PostgreSQL or MySQL administration, reverse proxy cookie settings, and your identity provider's logout and token behavior. Someone must be able to test logout from every entry point, including embedded dashboards and API clients, and to read logs when a session is not revoked. If those skills are spread across people who rarely work together, a partner can take the design and test plan while your staff run the production change.

How long does session testing take with many roles and integrations?

Testing time grows with the number of user populations, roles, identity flows and embedded applications that depend on sessions. A small deployment with one login path and no embedding needs a short test cycle. A deployment with several roles, OAuth2 and LDAP paths, scheduled reports and iframe embedding needs a test for each combination: login, idle timeout, absolute lifetime, logout from one tab, logout while a second device is active, and session reuse after a SECRET_KEY rotation. Ask the partner for a written test matrix that lists these cases and states how long each cycle will take in your environment, and confirm the staging environment matches production closely enough to trust the results.

What do we need to provide before session work starts?

Before work starts, the team usually needs access to the Superset configuration and deployment files, a staging environment that mirrors production, and a way to test the change against the real identity provider. The following are typically required:

  • Read and write access to superset_config.py and the deployment manifests, plus the ability to restart web and worker processes.
  • A staging copy of the metadata database and a non-production identity provider tenant or realm.
  • Administrator access to the identity provider, to change session and logout settings and to review its token lifetimes.
  • Named owners for the Redis or database service, the reverse proxy, and the embedding application, if one exists.

Confirm these items in the written scope so access is not the reason the schedule slips.

Will existing users be logged out during the session change?

Yes, you should plan for users to be signed out. Existing cookie sessions are signed with the current SECRET_KEY and stored in the browser, so changing the session backend or the lifetime settings typically invalidates them when the new configuration takes effect. Server-side sessions created after the change will be stored in Redis or the database instead. Schedule the cutover outside peak hours, announce it to users, and confirm with the partner how embedded dashboard sessions and scheduled reports behave during the restart. Test whether your identity provider keeps its own session, because users may be re-authenticated silently after the change.

What should a written quote for session work include?

A written quote should match the agreed scope and show the cost components separately. Ask for the following:

  • Discovery and design of the session backend, lifetime settings and cookie flags for your instances.
  • Configuration changes, deployment updates and identity provider alignment, with the systems named.
  • The test matrix, the staging work, and the production cutover and rollback steps.
  • Documentation for operators and a handover session for your team.
  • Which items are one-time work and which, such as a retainer for upgrades or testing after future Superset releases, recur.

Also ask which assumptions the quote depends on, such as the number of instances and whether embedding is in scope. DeployOpen does not publish a price list, so the quote follows from that written scope.

How DeployOpen scopes and delivers session hardening

DeployOpen treats server-side sessions and session lifetime in Apache Superset as a scoped change to your running deployment, not a configuration tweak. We agree the session backend, lifetime, cookie flags and embedding needs in writing, then build, test and document the change in your own infrastructure so your team can operate it afterward.

How we scope

  • Inventory current login, logout and cookie behavior against your identity provider and session requirements
  • Agree the session backend choice, Redis or metadata database, and who operates it
  • Record which iframe embedding and public dashboard flows must keep working under the chosen SameSite setting
  • Confirm the written scope, deliverables and timeline before any configuration change starts

How we build

  • Configure the server-side session backend and session lifetime in your staging environment first
  • Set secure cookie flags and SameSite behavior, then test logout invalidates sessions on every replica
  • Verify SECRET_KEY handling and the reverse proxy settings that carry session cookies to users
  • Run the same test cases against each Superset version you plan to run in production

How we hand over

  • Deliver the configuration files, change record and a documented session lifetime and cookie policy
  • Provide a written test script covering logout, timeout, concurrent sessions and embedded dashboards
  • Walk your platform and security teams through the backend, its failure modes and its monitoring
  • Document the upgrade steps for session settings, including what to recheck after each Superset release

How we support

  • Fixed-scope engagements end at the agreed handover, with support terms defined in the written scope
  • Ongoing support, upgrades and continuous testing are available as a retainer
  • Retainer work can include retesting session behavior after patches and Superset version upgrades
  • Ask us to confirm which support terms and retesting cadence apply before you sign

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.