Home/Blog/How to Fix phpMyAdmin Session Expired / Token Mismatch (2026)

How to Fix phpMyAdmin Session Expired / Token Mismatch (2026)

Database admin login screen with expired session hourglass, phpMyAdmin interface concept

You step away from phpMyAdmin for a few minutes, come back, click something — and get “Error: Token mismatch” or a session expired message. A phpMyAdmin session expired fix is usually quick: phpMyAdmin’s security tokens are tied to your PHP session, and when that session dies, every token becomes invalid. This 2026 guide explains why it happens and how to stop it interrupting your database work.

Here is what is happening. phpMyAdmin protects every action with a CSRF token stored in your PHP session. PHP sessions expire after inactivity (controlled by session.gc_maxlifetime, often 24 minutes by default). When the session is garbage-collected while your browser tab is still open, the next click sends an old token that no longer matches anything — hence “token mismatch.” Multiple tabs, cleared cookies, or a full session directory cause the same failure.

What Causes phpMyAdmin Session Expiry

  • PHP session timeout: session.gc_maxlifetime expired during idle time.
  • Cleared browser cookies: the session cookie was deleted while the tab stayed open.
  • Multiple tabs or logins: a new login invalidates tokens in older tabs.
  • Full or unwritable session directory: PHP cannot write session files (disk full or permissions).
  • Server time changes: clock adjustments invalidating session lifetimes.
  • Load balancer without sticky sessions: requests landing on different backend servers.

How to Fix phpMyAdmin Session Expired: 7 Steps

Step 1: Log out and log back in

The instant fix: log out of phpMyAdmin completely, close the tab, clear cookies for the phpMyAdmin domain, and log in fresh. This gives you a new session with valid tokens.

Step 2: Use one tab only

Close duplicate phpMyAdmin tabs. Each new login regenerates the session token, silently invalidating every other open tab. One tab per server avoids the whole class of problems.

Browser cookies being cleared with refresh symbol, session token renewal concept

Step 3: Increase the session lifetime

In php.ini, raise session.gc_maxlifetime = 3600 (1 hour) and restart PHP. In phpMyAdmin’s config.inc.php you can also set $cfg['LoginCookieValidity'] = 3600; — but it cannot exceed the PHP session lifetime, so raise both together.

Step 4: Check the session save path

Verify session.save_path in php.ini points to a directory that exists and is writable by the web server user. A missing or permission-broken session directory produces endless token mismatches. Also check the disk is not full — PHP silently fails to write sessions on a full disk.

Step 5: Disable aggressive cookie cleaners

Browser extensions or “privacy” tools that auto-delete cookies will nuke the phpMyAdmin session cookie. Whitelist your phpMyAdmin domain in such tools, or pause them while doing database work.

Step 6: Fix the server clock

Ensure the server clock is correct and synced via NTP. A clock jumping backwards can instantly expire sessions. Run timedatectl status to check.

Step 7: Enable sticky sessions (load-balanced setups)

Behind a load balancer, enable session affinity so each client sticks to one backend. Without it, requests bounce between servers that do not share session storage. Alternatively, move PHP sessions to a shared store like Redis. For broader database access issues, see our MySQL 1045 access-denied guide.

How to Prevent Session Expiry

  • Set session.gc_maxlifetime and LoginCookieValidity to match your working habits (1–2 hours).
  • Keep only one phpMyAdmin tab open per server.
  • Do not clear cookies mid-session.
  • Monitor disk space on the session partition.
  • Use a dedicated browser profile for admin work with no cookie cleaners.

Conclusion

phpMyAdmin “token mismatch” is just an expired PHP session wearing a security uniform: log back in for instant relief, then raise the session lifetime and keep one tab open to stop it recurring. With sane timeouts and a writable session directory, the error disappears for good. For more database admin fixes, browse the KamiWeb blog.