phpmyadmin logs out after 1440 secs

2019-01-30 01:33发布

问题:

In my local development Ubuntu box I use MySQL and phpmyadmin to work with the database.

Whenever phpmyadmin is idle for 1440 secs (24min) the session expires. I lose my place and have to login and start over.

I tried changing the $cfg['LoginCookieValidity'] = 3600 * 9; inside config.inc.php but it still times out in 1440 seconds.

I have restarted everything and cleared the browser cache (Firefox history -> Clear recent history -> Cache -> Everything).

I'm not sure why the increased timeout does not take effect. What am I doing wrong?

回答1:

Go to PHPMyAdmin in your browser

Settings > Features > Change the value of Login cookie validity > Save



回答2:

Add this line to /config.inc.php:

$cfg['LoginCookieValidity'] = 36000;

In /setup/lib/index.lib.php

$cf->getValue('LoginCookieValidity') > 36000;

If you don't already have a .htaccess file for your phpMyAdmin site, create one, and add the following line to override the default PHP session timeout:

php_value session.gc_maxlifetime 36000

I would not recommend altering this value in your main php.ini file, as it will allow a ridiculously long session timeout for all your PHP sites.

source: http://www.sitekickr.com/blog/increase-phpmyadmin-timeout/



回答3:

We can change the cookie time session feature at:

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

I found the answer in here.. No activity within 1440 seconds; please log in again



回答4:

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:

$cfg['LoginCookieValidity'] 

or

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. You will then get another 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.


回答5:

There seems to be UI for changing phpmyadmin configurations Start apache and click the following link

http://localhost/phpmyadmin/setup/index.php?page=form&formset=Features#tab_Security



回答6:

Steps for doing this using phpMyAdmin settings without any problem or requirements to change configs in php my.ini or defining .htaccess file:

  1. Goto your phpmyadmin path and find create_tables.sql in one of its subfolders (phpMyAdmin/sql/create_tables.sql in my 4.4.9 version.) and execute whole file contents on your current phpMyAdmin site from your web browser. This will create a database named phpmyadmin which can keep all your phpMyAdmin options saved permanently.
  2. In phpMyAdmin's config.inc.php find the commented line $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin'; and uncomment it (Now phpMyAdmin will use that custom database we generated in previous step).
  3. Goto phpMyAdmin from web browser and goto Server >> Settings >> Features >> "Login Cookie Validity" as in picture described by Pavnish and set the desired value. It works now.

References: Niccolas Answer ,PhpMyAdmin Configuration Storage, flashMarks Answer



回答7:

You should restart apache or httpd, not mysqld

sudo service httpd restart

or

sudo /etc/init.d/apache2 restart


回答8:

1) Login to phpMyAdmin 2) From the home screen click on "More settings" (middle bottom of screen for me) 3) Click the "Features" tab/button towards the top of the screen. 4) For 20 days set the "Login cookie validity" setting to 1728000 5) Apply.

php xampp



回答9:

You will then get another 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.“. That makes sense because php’s session will time out first anyways. So we will need to change /etc/php.ini .

session.gc_maxlifetime = 43200
That’s 12 hours in seconds. 

Restart your apache server and you are done!

source: http://birdchan.com/home/2011/06/06/phpmyadmin-timeout-after-1440-seconds/

this works for me! :)



回答10:

You just Increase the phpMyAdmin Session Timeout, open config.inc.php in the root phpMyAdmin directory and add this line.

from the wamp folder path wamp\apps\phpmyadmin4.0.4\config.inc.php

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

Example

$cfg['LoginCookieValidity'] = '1440';

Note: short cookie lifetime is all well and good for the development server not for your production server.



回答11:

It is not working. The PHP session will expire anyway after 1440 seconds.

Change in PHP.ini this too:

session.gc_maxlifetime = 3600

http://www.phpmyadmin.net/documentation/Documentation.html#config

Also, from PHP.ini:

If you are using the subdirectory option for storing session files

; (see session.save_path above), then garbage collection does not

; happen automatically. You will need to do your own garbage

; collection through a shell script, cron entry, or some other method.

; For example, the following script would is the equivalent of

; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):

; cd /path/to/sessions; find -cmin +24 | xargs rm



回答12:

change in php.in file from wampicon/php/php

session.gc_maxlifetime = 1440

to

session.gc_maxlifetime = 43200


回答13:

To set permanently cookie you need to follow some steps

Goto->/etc/phpmyadmin/config.inc.php file

add this code

$cfg['LoginCookieValidity'] = <cookie expiration time in seconds > 


回答14:

If the parameter $cfg['LoginCookieValidity'] is not taking effect in config.inc.php file, try disabling the session.gc_maxlifetime in the php.ini file by putting a semicolon to the left like this:

; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
; http://php.net/session.gc-maxlifetime
; session.gc_maxlifetime = 1440

Or try disabling both $cfg['LoginCookieValidity'] and session.gc_maxlifetime = 1440 by commenting both out.

Then phpMyAdmin should no longer log out when you idle. It works for me on Windows. Don't forget to clear your browser cache and restart your webserver.



回答15:

steps to change cookie expiration

step 1:Go to settings of Phpmyadmin

step 2:General

step 3:Login cookie validity

step 4:Update 1440 seconds default cookie expiration time with your new value



回答16:

If you have phpmyadmin configuration storage setup, the settings will be pulled out of your phpmyadmin.pma__userconfig table, and will override anything you have in config.inc.php. In this table, each MYSQL user can be assigned a different set of phpmyadmin settings.



回答17:

I have found the solution and using it successfully for sometime now.

Just install this Addon to your FF browser.



回答18:

After I tried all suggested methods here and still kept getting logged out, I turned to writing a small usercsript for Tampermonkey as I already have that extension. It is very simple and just sends a request to one of low footprint scripts of PHPMyAdmin once every minute. Here is the code:

// ==UserScript==
// @name         PHPMyAdmin Keep Session Alive
// @namespace    https://www.bitwizeor.io/
// @version      0.1
// @description  No more nasty PHPMyAdmin session expiries
// @match        http://localhost/phpmyadmin/*
// ==/UserScript==

(function() {
    'use strict';
    console.log('PHPMyAdmin Keep Session Alive activated');
    var url;
    window.setInterval(function(){
        url = $("#serverinfo a:eq(1)").prop("href");
        url += '&ajax_request=true&ajax_page_request=true';
        $.getJSON(url);
        console.log('pinging ...');
    }, 60000);
})();


回答19:

You can increase the session timeout in phpMyAdmin simply by following these steps:

Login to phpMyAdmin.

Select “Settings” from the top navigation bar.

Click “Features”

Locate the “Login cookie validity” field.

Change the value for this field to something greater than 1440.



回答20:

It worked for me after I

  • changed the $cfg['LoginCookieValidity'] in (phpmyadmin folder)/libraries/config.default.php to 999999999.

  • checked the php.ini used by the phpmyadmin by php5 -i | grep php.ini.

  • went to the php.ini file whose path I got from the grep command output and changed the session.gc_maxlifetime value to 999999999.

  • restarted the server. In my case it was sudo service apache2 restart.

Done. Logged in phpmyadmin and checked the cookie validity in Settings -> Features -> General -> Login cookie validity. It was 999999999. Also there was no warning "Your PHP parameter session.gc_maxlifetime is lower that cookie validity ...". The warning showed after I logged in phpmyadmin before I changed the php.ini file.

Check the version of php used by the phpmyadmin. You should change the ini file of the php that is used by the phpmyadmin. I have php5 and php(i.e 7) both installed. But my phpmyadmin uses php5. So I had to search for ini file of php5.



回答21:

===method 1 with http login===

[php.ini]
session.gc_maxlifetime = 86400

[config.inc.php]

$cfg['Servers'][$i]['auth_type']     = 'http';

===method 2 with cookie login===

[php.ini]

session.gc_maxlifetime = 86400

[config.inc.php]

$cfg['Servers'][$i]['auth_type']     = 'cookie';

$cfg['Servers'][$i]['LoginCookieValidity'] = 86400;

$cfg['Servers'][$i]['pmadb']         = 'phpmyadmin';

$cfg['Servers'][$i]['controluser']   = 'phpmyadmin_pma';

$cfg['Servers'][$i]['controlpass']   = 'nigookike';

$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig'; // there's a lot of other table required for full functionality,
                                                                         // all others can be left out unconfig except this one

[mysql]
-import phpMyAdmin/sql/create_tables.sql

-grant PRIVILEGES to phpmyadmin_pma as below

db/table

phpmyadmin  ALL PRIVILEGES 

mysql/db    SELECT

mysql/host  SELECT

mysql/tables_priv   USAGE

mysql/user  USAGE


-clear all entries should old one exists

phpmyadmin/pma__userconfig

[webUI]

-clear broswer cookie

-as normal mysql user, access http://mysql/phpmyadmin , at the bottom of page:

    The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. [Find out why.]

-near top of the page

    [Create missing phpMyAdmin configuration storage tables.]

-access http://mysql/phpmyadmin > settings > features > Login cookie validity > 86400 > [apply]

-check phpmyadmin/pma__userconfig contain new entries of aforemention mysql user

N.B.

  1. every user has independent setting and [webUI] procedure has to be repeated for each user

  2. if "The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. [Find out why.]"

link does not appears on frontpage, go settings > features > warnings > Missing phpMyAdmin configuration storage tables > [refresh] a few times will make it appears