phpmyadmin Failed to set session cookie. Maybe you are using HTTP instead of HTTPS

phpmyadmin Failed to set session cookie. Maybe you are using HTTP instead of HTTPS

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

PHPMyAdmin Failed to set session cookie. Maybe you are using HTTP instead of HTTPS

When you encounter the error Failed to set session cookie immediately after accessing phpMyAdmin, the culprit is almost certainly a mismatch between your transport layer security and your session configuration. This isn't a bug in Apache, MySQL, or the PHP interpreter itself; it is a deliberate security enforcement mechanism built into modern web servers and PHP sessions.

If you are accessing phpMyAdmin via an unencrypted http:// connection, the browser will refuse to store the session cookie on your hard drive if the server attempts to send it with the Secure flag. By default, production-grade PHP installations set session.cookie_secure to 1 (true). This ensures that cookies containing sensitive session IDs only travel over encrypted channels. If you ignore this and try to run phpMyAdmin over plain HTTP, the browser blocks the cookie, resulting in the "Failed to set session cookie" error every time you refresh the page or navigate away.

To resolve this, you must align your access method with your server's security posture. The most robust solution is to ensure you are accessing phpMyAdmin exclusively via HTTPS. If you have a valid SSL certificate installed on your Apache or Nginx server and your virtual host configuration redirects all traffic to the secure port (443), this error should vanish immediately.

Configuring PHP for HTTP Access

If you are in a development environment where HTTPS is not yet feasible, or if you simply need to test locally without SSL, you can bypass the restriction by modifying your PHP configuration. You have two primary options depending on how your PHP setup is managed.

Option 1: Modifying php.ini

Locate your active php.ini file. If you are using a custom configuration file loaded via Apache's LoadModule or specific directives, ensure those changes apply to the environment accessing phpMyAdmin. Add or modify the following lines:

session.cookie_secure = 0
session.cookie_httponly = 0
  • session.cookie_secure = 0: Allows cookies to be sent over both HTTP and HTTPS connections.
  • session.cookie_httponly = 0: Prevents JavaScript from accessing the cookie (good for security), but setting this to 0 allows legacy scripts to read it if needed, though phpMyAdmin handles its own authentication logic.

After saving these changes, you must restart your Apache service to apply the new configuration:

sudo systemctl restart apache2
# or
sudo systemctl restart httpd

Option 2: Using .user.ini (Easiest for Local Development)

If you are working in a local environment like XAMPP, MAMP, or using PHP built-in server, modifying php.ini might be cumbersome. Instead, create a file named .user.ini in the root directory of your web site where phpMyAdmin is installed (or in your home directory for system-wide defaults).

session.cookie_secure = 0

This file takes precedence over php.ini for user-level configurations and requires no Apache restart.

The Security Trade-off

While disabling the Secure flag fixes the error, it reintroduces a significant security vulnerability: Session Hijacking via Man-in-the-Middle (MitM) attacks. If you run phpMyAdmin over HTTP with session.cookie_secure = 0, an attacker on the same network can intercept the session ID and gain full access to your database without needing credentials.

In a production environment, this is not a viable trade-off. You should strictly enforce HTTPS. The modern web standard expects sensitive applications like database management tools to operate exclusively over TLS. If you are setting up a new server for hosting phpMyAdmin, the correct architectural decision is to install an SSL certificate (using Let's Encrypt via Certbot, for example) and configure Apache to redirect all HTTP traffic to HTTPS automatically.

Verifying the Fix

Once you have adjusted the configuration or switched to HTTPS, clear your browser cache and cookies. Attempt to access phpMyAdmin again. If the connection is secure and the PHP configuration matches, the session cookie will be accepted, and the dashboard should load without error. If you continue to see the failure message after confirming HTTPS usage and checking your php.ini settings, verify that no other modules (such as specific firewall rules or corporate proxy interceptors) are stripping cookies or forcing HTTP headers on the connection.

Our network