Configuring MFA Session Length in ExpressionEngine 7.6

Multi-Factor Authentication (MFA) has been available in ExpressionEngine since version 6.2 (originally introduced in ExpressionEngine Pro in January 2022) and has been built directly into ExpressionEngine core since version 7.0 (August 2022). It is one of the highest-impact steps you can take to protect Control Panel editors, administrators, and front-end member accounts.

In ExpressionEngine 7.6, the new $config['mfa_session_length'] configuration override lets you define how long a verified MFA check is remembered between login sessions, measured in seconds. It is opt-in by default, giving you full control over how frequently your team is prompted for a verification code.


Quick Refresher: Turning On MFA

If your site already uses Multi-Factor Authentication, you can jump straight to Prerequisites. If you are enabling MFA for the first time, here is the three-part setup inside the Control Panel:

  1. Enable MFA globally: Go to Settings → Members and make sure Enable Multi-Factor Authentication? is turned on.
  2. Require MFA for specific roles (optional): Go to Members → Roles, open a role, and enable Require Multi-Factor Authentication if you want all members in that role to enroll on their next login.
  3. Enroll your account: Open Members → Profile → Multi-Factor Authentication (or press ⌘J / Ctrl+J to open the Jump Menu and type MFA), toggle MFA on, scan the QR code with an authenticator app (such as 1Password, Authy, or Google Authenticator), save your backup code in a secure password manager, and confirm your 6-digit verification code.

Member Settings in ExpressionEngine showing the Enable Multi-Factor Authentication toggle turned on Enable Multi-Factor Authentication globally under Settings → Members.

Role settings screen highlighting the Require Multi-Factor Authentication toggle Enforce MFA for specific teams or access levels under Members → Roles → [Role].

Member profile Multi-Factor Authentication page showing the personal Enable Multi-Factor Authentication toggle Individual members manage their own MFA enrollment under Members → Profile → Multi-Factor Authentication.

Prefer a walkthrough video? Watch Tuesday Tips with Tom: Multi-Factor Authentication in ExpressionEngine on YouTube for a quick step-by-step tour of enabling MFA via the Jump Menu, requiring MFA by Member Role, scanning the QR code, storing your backup code, and logging in with a verification code.


Prerequisites

Before configuring mfa_session_length, confirm that your site meets three requirements:

  1. ExpressionEngine 7.6.0 or newer: The mfa_session_length override and its accompanying MFA session handling were introduced in ExpressionEngine 7.6.0.
  2. MFA is enabled: Under Settings → Members, Enable Multi-Factor Authentication? must be turned on (or $config['enable_mfa'] = 'y' / unset, since it defaults to enabled).
  3. Cookie-based sessions are enabled: Because MFA approval relies on an HTTP-only cookie, your session type must use cookies. Navigate to Settings → Security & Privacy and confirm that CP session type (cp_session_type) and/or Website Session type (website_session_type) is set to Cookies only (c) or Cookies and session ID (cs). If a session type is set to Session ID only (s), mfa_session_length is ignored for that area.

Security and Privacy settings showing CP session type and Website Session type set to Cookies only Make sure CP session type and Website Session type use Cookies only or Cookies and session ID. mfa_session_length is disabled when set to Session ID only.


Configuring $config['mfa_session_length']

By default, mfa_session_length is unset (equivalent to 0), which disables remembering MFA between login sessions and preserves ExpressionEngine’s existing behavior. To enable MFA session reuse, set mfa_session_length to a positive integer representing the desired duration in seconds.

Set the configuration value in your config.php file.

Add it to system/user/config/config.php

Open system/user/config/config.php and add $config['mfa_session_length']:

// Remember MFA verification for 7 days (in seconds)
$config['mfa_session_length'] = 604800;

To disable MFA session reuse at any time, remove the line or set it to 0:

// Disable remembering MFA verification between login sessions (default)
$config['mfa_session_length'] = 0;

Common Duration Reference

Duration Value (Seconds) Typical Use Case
Disabled (default) 0 or unset Strict compliance environments, shared devices, or prompting on every login
8 hours 28800 Single workday before requiring a fresh code
24 hours (1 day) 86400 Daily MFA verification for active editors
7 days (1 week) 604800 Balanced default for trusted agency and editorial teams
14 days (2 weeks) 1209600 Low-friction setup for trusted internal teams
30 days 2592000 Extended convenience window on managed personal devices

Verifying Your Configuration in Cookie Settings

ExpressionEngine 7.6 registers the MFA Session cookie (exp_mfa_session) in the built-in Cookie Registry as a Necessary cookie, making it easy to verify your active setting right inside the Control Panel.

  1. Go to Settings → Cookie Settings (settings/pro/cookies).
  2. Under Necessary Cookies, locate MFA Session (exp_mfa_session). The Lifetime column displays the active $config['mfa_session_length'] value in seconds (for example, 86400 for 24 hours).

Cookie Settings page listing MFA Session (exp_mfa_session) under Necessary Cookies with a lifetime of 86400 seconds In Settings → Cookie Settings, MFA Session (exp_mfa_session) appears under Necessary Cookies with its current mfa_session_length value.

  1. Click the Manage (gear) icon on the MFA Session row to inspect its details.

Manage screen for exp_mfa_session showing the read-only Lifetime field set to 86400 and referencing mfa_session_length The Lifetime field for exp_mfa_session is intentionally read-only in the Control Panel and mirrors $config['mfa_session_length'] from config.php.

You can still edit the Cookie Title and Cookie description here if your site outputs cookie disclosures via template tags, while the Lifetime field remains locked to $config['mfa_session_length'] so security policy stays version-controlled in config.php.


How mfa_session_length Works & Built-in Security Safeguards

ExpressionEngine 7.6’s MFA session implementation is designed to cut down on repetitive prompts without weakening account authentication. Understanding the exact boundaries makes it easier to pick the right duration for your site.

Decoupled from “Remember Me”

$config['mfa_session_length'] only remembers that a browser passed an MFA check. It never keeps a user logged in on its own:

Fixed Window Checked Only at Authentication Boundaries

The approval window starts from the exact timestamp when the user verified their 6-digit code (verified_at). It is a fixed window, not a sliding one:

Site-Isolated, Hardened Cookies Across CP and Front-End

MFA session reuse works consistently for both Control Panel and front-end logins. Under the hood, ExpressionEngine stores a cryptographically random approval token in a site-isolated, host-only cookie (exp_mfa_session_{site_id} governed by the mfa_session cookie policy) with strict transport flags:

Automatic Revocation & 7.6 Security Hardening

ExpressionEngine immediately invalidates remembered MFA approvals whenever a user logs out or account security credentials change:


Recommended Values & Best Practices

There is no single right number for every site. Choose a duration that fits how your team works and the sensitivity of the content they manage:

A few practical habits pair well with mfa_session_length:


Conclusion & Helpful Links

$config['mfa_session_length'] brings a much-requested quality-of-life improvement to ExpressionEngine 7.6: you can keep MFA required for your team without making every session timeout feel like a speed bump, while retaining fixed windows, automatic revocation on logout or credential changes, and strict cookie protections.

For further reading and setup resources:

Comments 0

Be the first to comment!