16

In phpMyAdmin I set the 'login cookie validity' to 1sec. As one can imagine, it now throws me out after 1 second of logging in. I can't change it back in phpMyAdmin fast enough so I need a manual alternative.

I don't want to reinstall phpMyAdmin as I will loose all of my databases. I also can't stay logged in long enough to export them. Is there a way to do this manually?

I've tried setting the session.gc_maxlifetime to 86400 in my php.ini file but it did nothing.

proPhet
  • 1,188
  • 4
  • 16
  • 39
  • possible duplicate of [How to change time limit in phpmyadmin (logging in)](http://stackoverflow.com/questions/2779288/how-to-change-time-limit-in-phpmyadmin-logging-in) – alexn Feb 02 '14 at 11:28
  • @alexn no it's not a duplicate, I looked at that discussion and the accepted answer says to adjust `maxlifetime` in `php.ini`. That did not work – proPhet Feb 02 '14 at 11:29
  • 2
    You should not look at the accepted answer but the most upvoted one. That should solve your problem. – alexn Feb 02 '14 at 11:31

3 Answers3

19

In your config.inc.php file set both the login cookie validity and the session max lifetime so that you won't get the following warning:

Your PHP parameter session.gc_maxlifetime is lower than cookie validity configured in phpMyAdmin, because of this, your login might expire sooner than configured in phpMyAdmin.

So put this in your config.inc.php file and you'll be fine (change the time accordingly to your neeeds):

$sessionValidity = 3600 * 24 * 365; // one year

$cfg['LoginCookieValidity'] = $sessionValidity;
ini_set('session.gc_maxlifetime', $sessionValidity);

Check also in your database, it may be worth temporarily disabling it so that the settings there do not override the ones in the config.inc.php file.

Francesco Casula
  • 26,184
  • 15
  • 132
  • 131
  • 1
    Newer versions often have /libraries/config.default.php with $cfg['LoginCookieValidity'] = around line 768. Just change the value. – TheSatinKnight Dec 31 '17 at 19:43
  • 2
    Good. just had to make sure in the second line, in the ini_set call that the $sessionValidity value is cast to a string: strval($sessionValidity) or (string)$sessionValidity – cdsaenz Oct 11 '20 at 03:24
4

in the config.inc.php file, which should be located in your phpadmin root folder, add this setting:

$cfg['LoginCookieValidity'] = 14400;

14400 is the number of seconds before timeout; 14400 is 4 hours. Of course, you can use whatever interval you like.

stevelinberg
  • 313
  • 2
  • 7
Asaf Magen
  • 862
  • 10
  • 22
  • 1
    It's also safe to set the value as a calculation: `$cfg['LoginCookieValidity'] = 3*3600; // hours * second per hours` – Martin Krung Jun 15 '15 at 13:24
2

Based on your question, it sounds like you changed it through the Settings tab within phpMyAdmin. If you have the phpMyAdmin Configuration Storage configured, that setting is stored there, if not it's just stored in your browser session so accessing from another browser or expiring that session/removing the cookie should do it. If it's in the phpMyAdmin Configuration Storage database you've got two means to get around it.

  1. Disable the database. Edit config.inc.php and temporary comment out the line about $cfg['Servers'][$i]['userconfig']. Log in, open the phpMyAdmin database (by default probably called phpmyadmin) and edit the userconfig table (by default pma__userconfig). You can click to edit the corresponding value in the config_data column or just delete that row entirely to reset all your preferences.
  2. Log in from the command line (or any other MySQL administrative tool), open the phpMyAdmin database (by default probably called phpmyadmin) and edit the userconfig table (by default pma__userconfig). You can edit the corresponding value in the config_data column or just delete that row entirely to reset all your preferences. This will require a bit of SQL ability (not a whole lot), so probably the first method is easier unless you're comfortable with the MySQL command line interface.

The standard disclaimers about backing up first apply, of course.

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43