How to change time limit in phpmyadmin (logging in)

后端 未结 6 1299
走了就别回头了
走了就别回头了 2021-01-04 03:11

I use phpmyadmin to create mysql database. And I have set the auth type to cookie in the config.inc.php. How do I change the time limit so that even if I logged in I stayed

相关标签:
6条回答
  • 2021-01-04 03:28

    In my case(4.3.8) just replace in config.inc.php cookie to config and add 2 lines like bellow:

    /*
     * First server
     */
    $i++;
    /* Authentication type */
    $cfg['Servers'][$i]['auth_type'] = 'config';
    $cfg['Servers'][$i]['username'] = 'root'; //add this line
    $cfg['Servers'][$i]['password'] = 'root'; //add this line
    
    0 讨论(0)
  • 2021-01-04 03:29

    Fast solution for Ubuntu:


    // edit php.ini and look for session.gc_maxlifetime
    sudo vi /etc/php5/apache2/php.ini

    // set to 24 hours
    session.gc_maxlifetime = 86400


    // edit config.inc.php and look for $cfg['LoginCookieValidity']
    sudo vi /etc/phpmyadmin/config.inc.php

    // set to 24 hours
    $cfg['LoginCookieValidity'] = 86400;


    // restart web server
    sudo service apache2 restart

    0 讨论(0)
  • 2021-01-04 03:33

    I know this question is getting old, but the above 'selected' answer doesn't actually work. That just sets the time til session data gets removed.

    After trying this and realizing it was failing, I spent some time reading through the phpmyadmin docs and found this:

    $cfg['LoginCookieValidity'] = 86400;
    $cfg['LoginCookieStore'] = 0;
    

    The first line is the amount of time until you're auto-logged out. These values need to be set in your phpmyadmin install folder, within the file config.inc.php.

    They were not there at all in my file but after adding them to the bottom it worked correctly. The first variable defines how long until you are logged out in seconds - I set mine to 1 day. The second variable is how long the cookie lasts. 0 means the cookie lasts til you close your browser.

    Setting up these two variables will have the desired effect. You could set both to some insane number and never log in, but that would be pretty insecure.

    0 讨论(0)
  • 2021-01-04 03:39

    I finally found the tricks, assuming you have at least the version 4.3.X :

    First, log to phpMyAdmin, once log in, click on Databases (located at the top menu)

    Then on the input text Create database, insert phpmyadmin and click on Create (you can select your wished charset, this is optional)

    When the database is created, click to it on the list (should appear with your other database)

    click to SQL and insert the contents of create_tables.sql located to your directory phpMyAdmin :

    /phpMyAdmin-(yourversion)-all-languages/sql/create_tables.sql
    

    You can optionally dump it in command line (terminal) :

    mysql phpmyadmin -u myMysqluser -pMypassword < create_tables.sql
    

    Now that's done, open your config.inc.php and uncomment those 2 lines :

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

    Note that if you don't uncomment the other $cfg['Servers'][$i], phpmyadmin will return :

    The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. Find out why. Or alternately go to 'Operations' tab of any database to set it up there.

    Which is just a warning concerning the other options available. (if you don't need them, let them comment)

    Logout and login again to phpMyAdmin and go to Settings (located at the top menu between Import and Replication) and click on Features you will see the option :

    Login cookie validity
    

    Where you have to put in seconds, the validity of the cookie.

    Click on Apply and it's done, the record will be save for this user in the table pma__userconfig in the database previously created (phpmyadmin), the record will look like this :

    {"LoginCookieValidity":21600,"Server\/hide_db":"","collation_connection":"utf8mb4_unicode_ci"}
    

    If the validity of your cookie (in seconds) is greater than your session_gc_maxlifetime, phpMyAdmin will return a warning :

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

    session_gc_maxlifetime is located to your php.ini, change it and restart your webserver if the above warning appear.

    0 讨论(0)
  • 2021-01-04 03:40

    Looking for this:

    ini_set('session.gc_maxlifetime', '3600');
    

    As per the comments - You can find it in php.ini file or run the above statement in your script where you are setting session

    0 讨论(0)
  • 2021-01-04 03:45

    You can avoid cookie authentication altogether and use

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

    in your config.inc.php file found under the phpmyadmin folder.

    This will keep you logged in forever.

    0 讨论(0)
提交回复
热议问题