209

I work on my wamp for localhost backend development everyday.

I feel annoyed by phpmyadmin auto log out out quickly. Is there any way I could get rid of this or extend the timeout?

Where can I set this timeout value?

Simon East
  • 55,742
  • 17
  • 139
  • 133
Jin You
  • 2,328
  • 2
  • 15
  • 19

2 Answers2

295

To increase the phpMyAdmin Session Timeout, open config.inc.php in the root phpMyAdmin directory and add this setting (anywhere).

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

Where <your_new_timeout> is some number larger than 1800.

Note:

Always keep on mind that a short cookie lifetime is all well and good for the development server. So do not do this on your production server.

Subedi Kishor
  • 5,906
  • 5
  • 35
  • 53
  • 8
    The UI says that user settings (such as the session timeout) will only be saved for the current session unless the permanent phpMyAdmin configuration storage is properly configured (which is probably not the case for a default WAMP installation). If this is true, setting the timeout in the config.inc.php might be better. – Jack Oct 16 '13 at 16:30
  • 18
    In ubuntu, `config.inc.php` is accessed fast and easy by `sudo gedit /etc/phpmyadmin/config.inc.php` – davidkonrad Nov 25 '14 at 17:10
  • 18
    I found that I also needed to add the following line to the config.inc.php file: ini_set('session.gc_maxlifetime', ); And, I'm pretty sure the two values need to be equivalent. BTW: [on my distro, at least] the config.inc.php file is in /etc/phpmyadmin/. – ReverseEMF Jun 19 '15 at 19:08
  • 8
    whatever you do, don't set it to 0 thinking that means never, it will actually instantly log you out once you log in.... – dangel Sep 27 '15 at 01:02
  • 1
    An anonymous user suggests: "just comment the //$cfg['Servers'][$i]['auth_type'] = 'cookie'; in your config.ini file" – cgmb May 07 '16 at 00:01
  • 3
    @dangel If you used the UI to set your timeout preference, any configuration you have in **config.inc.php** seems to be overridden. So, if you do happen to lock yourself out by setting timeout to 1, you can comment out `$cfg [‘Servers’][$i][‘auth_type’] = 'cookie';` and replace it with `$cfg['Servers'][$i]['auth_type'] = 'http';` – andromeda Aug 17 '16 at 06:38
  • 2
    make sure to modify session.gc_maxlifetime also otherwise you'll get a " 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." – Robert Sinclair Sep 13 '16 at 22:14
  • 2
    @subedi-kishor another thing to mention is `session.gc_maxlifetime`, which has to be the same as `LoginCookieValidity`, otherwise the smaller value will be the actual value. – machineaddict Nov 26 '18 at 09:43
  • 1
    This answer is not working for me as of December 2018, might be deprecated – NaturalBornCamper Dec 06 '18 at 15:52
  • There are two files. `/usr/share/phpMyAdmin/setup/frames/config.inc.php` and `/usr/share/phpMyAdmin/test/test_data/config.inc.php` In the first file, I see no `$cfg` variable already declared. How does this solution work? In the test version of the file (2nd file), I do see the `$cfg` variable. Is test really the correct place to configure production phpmyadmin? – ahnbizcad Mar 11 '19 at 17:21
  • Every config in the test file is in this format `$cfg['Servers'][$i]['auth_type'] = 'cookie';`. Should we instead of `$cfg['LoginCookieValidity'] = ;` be typing in `$cfg['Servers'][$i]['LoginCookieValidity'] = 12345;`? ` – ahnbizcad Mar 11 '19 at 17:26
  • I'm sure that's the case, ahn, but anyway, note that the answer says to **add** the cfg option. It does not already exist... for some reason. – Vael Victus Jun 17 '19 at 12:32
  • How do you find config.inc.php? my etc/phpmyadmin folder is empty. On ec2 – Curtis Sep 28 '19 at 06:13
  • For Ubuntu 18.04 the file is `/usr/share/phpmyadmin/libraries/config.default.php` – Ahmed Ismail Dec 11 '19 at 11:49
  • @AhmedIsmail Right at the beginning of `/usr/share/phpmyadmin/libraries/config.default.php` there is a big warning saying `DO NOT EDIT THIS FILE, EDIT config.inc.php INSTEAD !!!` – rlcabral Jul 06 '20 at 10:32
  • Please keep in mind the newer versions of xampp bitnami, this param is already set there with a value of 1440, just you need to update and add your own timeout there! – Naser Nikzad Jul 21 '20 at 09:08
  • You can and should set `session.gc_maxlifetime` in the config too. Probably best to add something like: `ini_set('session.gc_maxlifetime', $cfg['LoginCookieValidity']);` – Nux Sep 29 '21 at 11:22
261

Once you're logged into phpmyadmin look on the top navigation for "Settings" and click that then:

"Features" >

...and you'll find "Login cookie validity" which is typically set to 1440.

Unfortunately changing it through the UI means that the changes don't persist between logins.

Chuck Le Butt
  • 47,570
  • 62
  • 203
  • 289
tfont
  • 10,891
  • 7
  • 56
  • 52
  • I sometimes wonder why they still bother making user interfaces, it seems like everyone still uses the command line and `ini` files for configuring their work environment... – Wilt May 02 '14 at 09:43
  • 11
    Way easier solution, this should be the accepted answer. – Select0r May 22 '14 at 06:45
  • 26
    This only works if you keep logging in -- as noted above, modifications to config.inc.php will persist between logins. – samson Nov 14 '14 at 20:27
  • 14
    On Ubuntu I need to change my global php.ini (/etc/apache2/php.ini) `session.gc_maxlifetime` value, because otherwise phpmyadmin can't use own settings. I think this apply to any OS. – sobi3ch Feb 09 '15 at 12:53
  • 12
    Note that you can't set a value greater than 9223372036854775806 or it will result in a integer overflow. – Mooncake Dec 10 '15 at 07:53
  • 13
    @LittleFinger - I'm sure you're correct, but that's hilarious. I'll give you a dollar if phpMyAdmin is still around in 300 million years and your login is still active. :) – squarecandy Mar 23 '16 at 01:32
  • 5
    `Server:localhost -> Settings -> Features -> General -> Login cookie validity` – Peyman Mohamadpour Jul 20 '16 at 06:35
  • 4
    @squarecandy come on be generous to LittleFinger. Put the dollar in a savings account, and given today's typical interest rates, in 300 million years, it could be worth... 2 dollars! – Tom Pace Jul 29 '16 at 19:52
  • This is the correct answer; does not require any file configuration. – Scott Byers Aug 08 '16 at 20:03
  • On WampServer this option gets reset as soon as it restarts. Need to actually change the PHPMyAdmin config file for it to stick. – kjdion84 Jan 08 '17 at 23:57
  • 1
    must be the accepted answer – Shady Mohamed Sherif Feb 24 '17 at 23:34
  • 5
    According to PHPMyAdmin changing this in the UI "will be saved for current session only." It's better to alter the `config.inc.php` as the other answer suggests. – Chuck Le Butt May 17 '17 at 13:10
  • 1
    how can I activate this setting? It is not available on the UI of the phpmyadmin 4.8.4. – Zoltán Süle May 09 '19 at 16:04
  • 4
    This feature no longer available in the GUI (verified as of phpMyAdmin 5.x) You'll need to do 2 things, add the line to config.inc.php i.e. $cfg['LoginCookieValidity'] = 3000; Then update your php.ini and make sure that value is >= session.gc_maxlifetime = 3000 then restart httpd and reload page – S.ov Feb 17 '20 at 22:38