phpmyadmin / docker

Docker container for phpMyAdmin
https://hub.docker.com/_/phpmyadmin
GNU General Public License v3.0
665 stars 456 forks source link

Prevent session timeout #375

Closed binarweb closed 2 years ago

binarweb commented 2 years ago

While working, the phpMyAdmin tab is left open. Sometimes, when I get back to it I'm logged out.

Is there a way to increase the session timeout of phpMyAdmin in docker to something like 30 days?

The container exposes phpMyAdmin to outside world, so I wouldn't use https://github.com/phpmyadmin/docker/issues/235#issuecomment-526636759.

binarweb commented 2 years ago

I managed to solve it. This issue can be closed.

I did it by mounting a config file to the phpmyadmin container.

The docker-compose.yml file content:

version: "3"
services:
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    environment:
      PMA_ARBITRARY: 1
    volumes:
      - ./config.inc.php:/etc/phpmyadmin/config.inc.php
    restart: always

The config.inc.php content:

<?php

# Extend session lifetime
$sessionValidity = 3600 * 24 * 365 * 1; // 1 year
$cfg['LoginCookieValidity'] = $sessionValidity; // http://docs.phpmyadmin.net/en/latest/config.html#cfg_LoginCookieValidity
ini_set('session.gc_maxlifetime', (string) $sessionValidity);
williamdes commented 1 year ago

Does this work nice for you since then ?

binarweb commented 1 year ago

It does work. But, I don't remember if I changed something else. I might have changed the cronjob or the systemd service for PHP to delay cleaning up stale sessions.

williamdes commented 1 year ago

It does work. But, I don't remember if I changed something else. I might have changed the cronjob or the systemd service for PHP to delay cleaning up stale sessions.

Okay, that's good to know. Thanks for the feedback

vespino commented 8 months ago

If you add the following to you yml file, you're able to control all PHP setting server based:

volumes:
  - ./custom.ini:/usr/local/etc/php/conf.d/custom.ini