98

How can I change the phpmyadmin automatic log out time?

It will log out automatically after 1440 seconds which is very low for me. How can I change the option or remove log in request completely?

0

9 Answers 9

122

Changing php.ini will change the session duration for all the websites running on the server. To change it just for PhpMyAdmin, open config.inc.php and add:

$sessionDuration = 60*60*24*7; // 60*60*24*7 = one week
ini_set('session.gc_maxlifetime', $sessionDuration);
$cfg['LoginCookieValidity'] = $sessionDuration;
11
  • 23
    there seems to be UI for setting config.php variables at localhost/phpmyadmin/setup/… - see Login Cookie Validity
    – psycho brm
    Commented Jan 23, 2013 at 14:07
  • This UI setting is a bit confusing but works for setting password in config for automatic login and set session expiration time. Upvote. Commented Feb 13, 2013 at 21:33
  • 1
    Unlimited time is kind of impossible because every cookie has a "Valid Until"-Date, but you can just enter a very high number. Commented Sep 30, 2014 at 5:14
  • 5
    This should be the answer. The question asked how to modify phpMyAdmin. This answer solves it specifically.
    – user1893702
    Commented Apr 28, 2015 at 20:28
  • 1
    You need to change cookie path too. Because if gc_maxlifetime is defined for an other website, the gc will delete all cookies the first time it is call for a website. You can add these 2 lines in the /etc/apache2/conf-available/phpmyadmin.conf file : php_admin_value session.gc_maxlifetime 604800 + php_admin_value session.save_path /var/lib/phpmyadmin/tmp
    – fred727
    Commented Sep 12, 2017 at 10:41
110

In PHPMyAdmin 4 this no longer appears in the config.inc.php file. Instead go to PHPMyAdmin in your browser. Ensure you are at the localhost level to see the Settings link. Then set Settings > Features > Change the value of 'Login cookie validity' > Save

instructions

6
  • N.B. there appears to be a limit on how many characters you can enter in this field. Commented Nov 19, 2014 at 0:09
  • 1
    The UI change doesn't work for me. It still log out too quickly, no matter how bigger the Login cookie validity is.
    – dani24
    Commented Sep 15, 2016 at 18:40
  • 4
    @dani24, did you get this notice: Your preferences will be saved for current session only. Storing them permanently requires phpMyAdmin configuration storage.? Click the link in this, and it will give you instructions for enabling the ability to permanently store changes.
    – Parapluie
    Commented Apr 7, 2017 at 17:54
  • phpMyAdmin will show this error. Your PHP parameter session.gc_maxlifetime is lower than cookie validity configured in phpMyAdmin, because of this, your login will expire sooner than configured in phpMyAdmin. You will have to apply Ravinder Singh's answer as well as this one. Commented May 16, 2017 at 17:12
  • 7
    Not available in version 4.8.4
    – Thanasis
    Commented Feb 2, 2019 at 9:56
90

Create or edit your php.ini file and set this variable value in it:

session.gc_maxlifetime = 1440

The integer is in seconds. 500000 seconds is 5.7 days. Then restart apache.

11
  • 2
    so open your php.ini file and increase the value of session.gc_maxlifetime, that's it. Commented Jun 30, 2012 at 9:54
  • 13
    bad answer, security issues! Commented Jan 21, 2014 at 15:52
  • 2
    You may also need to update $cfg['LoginCookieValidity'] in the phpmyadmin config.inc.php file. Commented Oct 28, 2014 at 20:39
  • 6
    @slaver113 In this case I'd say the security is fine as it's a development environment, this is NOT fine for any production environment. I'd prefer to see this mentioned in the answer.
    – Manuel
    Commented Dec 5, 2014 at 14:37
  • 9
    This has nothing to do with PHPMyAdmin's timeout. I don't know why it's so highly voted. It's not even related to the question.
    – felwithe
    Commented Sep 11, 2016 at 15:15
13

You can change the cookie time session feature at phpmyadmin web interface

Settings->Features->General->Login cookie validity

OR

If you want to change the 'login cookie validity' in configuration file, then open the phpmMyAdmin configuration file, config.inc.php in the root directory of PHPMyAdmin.(root directory is usually /etc/phpmyadmin/)

After locating the config.inc.php , search for the line below and set it to the value of seconds you want phpmyadmin to timeout:

['LoginCookieValidity'] 

If you couldn't find the above line, just add the following:

$cfg['Servers'][$i]['LoginCookieValidity'] = <your_new_timeout>;

For example:

$cfg['Servers'][$i]['LoginCookieValidity'] = 3600 * 3;

The Timeout is set to 3 Hours from the Example above.

session.gc_maxlifetime might limit session validity and if the session is lost, the login cookie is also invalidated. So, we may need to set the session.gc_maxlifetime in php.ini configuration file(file location is /etc/php5 /apache2/php.ini in ubuntu).

session.gc_maxlifetime = 3600 * 3


phpMyAdmin Documentation on LoginCookieValidity

$cfg['LoginCookieValidity']

Type: integer [number of seconds]
Default value: 1440

Define how long a login cookie is valid. Please note that php configuration option session.gc_maxlifetime might limit session validity and if the session is lost, the login cookie is also invalidated. So it is a good idea to set session.gc_maxlifetime at least to the same value of $cfg['LoginCookieValidity'].

NOTE:

  1. If your server crashed and cannot load your phpmyadmin page, check your apache log at /var/log/apache2/error.log. If you got PHP Fatal error: Call to a member function get() on a non-object in /path/to/phpmyadmin/libraries/Header.class.php on line 135, then do a chmod 644 config.inc.php. that should take care of the error.
  2. If you get the warning: Your PHP parameter session.gc_maxlifetime is lower that cookie validity configured in phpMyAdmin, because of this, your login will expire sooner than configured in phpMyAdmin., then change the session.gc_maxlifetime as mentioned above.
7

For LOCAL installs only, you can remove the login and timeout altogether - this seems to be what you're after. By changing the authorization type to "config" and entering your database username and password in your config file you are automatically logged in. Add to config.inc.php:

$cfg['Servers'][$i]['verbose'] = '';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'username';
$cfg['Servers'][$i]['password'] = 'password';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

Of-course if you do this on a server on the internet, some cheeky chappy will come along and gleefully download all your passwords and delete your website. This is for a development server running on your own laptop only.

An easier way to customise phpmyadmin these days is to go to http://www.example.com/phpmyadmin/setup/ , save all your settings section at a time, click save or download at the bottom, copy the file generated to your root phpmyadmin directory, then chmod it. You have to turn off write permission even if it is a local server as phpmyadmin checks this before it lets yo log in.

1
  • The file name is wrong, not a big issue as most will understand what you mean. The correct name nevertheless is config.inc.php
    – David
    Commented Nov 12, 2019 at 16:48
3

Explore directory 'apps\phpmyadmin4.5.2' in your wamp folder and open config.inc.php file. Then add this line under existing code.

'$cfg['LoginCookieValidity'] = 3600 * 10; //login cookie validity extended upto 10 hours'.

That's all...

2

For phpMyadmin 5.0.2 running on Ubuntu 18.04, I edited the file as follows:

  1. sudo nano /usr/share/phpmyadmin/libraries/classes/Config/Forms/User/FeaturesForm.php

  2. find the method public static function getForms() and added LoginCookieValidity field

    public static function getForms()
    {
        $result = [
            'General' => [
                'VersionCheck',
                'NaturalOrder',
                'InitialSlidersState',
                'LoginCookieValidity', //Added this line if it missing
                ...........
          }
    
  3. save the file and now you will be able to change the value from user interface.

[Settings -> General -> Features -> Login Cookie Validatity]

1
  • Thanks for this. I was looking at the answers above, and back at my 5.0.2 installation, and thinking I was losing my mind! Wonder why they removed the UI, especially if it's still there ready to be reenabled?
    – Headbank
    Commented Aug 8, 2020 at 11:41
0

Server:localhost -> Settings -> Features -> General -> Login cookie validity

4
  • The same answer was already posted long time ago (and with explanation + information about the php session timeout which your answer lacks).
    – Marki555
    Commented Jul 20, 2016 at 8:37
  • Although I didnt mention, I always prefer super simple answers for some type of questions. Commented Jul 20, 2016 at 9:04
  • 1
    Yes, but if you set login cookie validity to higher value than the session validity in php, it won't work.
    – Marki555
    Commented Jul 20, 2016 at 13:08
  • I did'nt know that. thanks for your informative comment :) Commented Jul 20, 2016 at 13:24
0

I have phpmyadmin 4.9.2. and try to config LoginCookieValidity, but I have auto logout :( If you using localhost you can try https://docs.phpmyadmin.net/en/latest/config.html#example-for-ip-address-limited-autologin

if ($_SERVER["REMOTE_ADDR"] == "127.0.0.1") {
    $cfg['Servers'][$i]['auth_type'] = 'config';
    $cfg['Servers'][$i]['user'] = 'root';
    $cfg['Servers'][$i]['password'] = 'yourpassword';
} else {
    $cfg['Servers'][$i]['auth_type'] = 'cookie';
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.