How to increase session timeout in php?

Sometimes php session timeouts quickly before your script execute. You can increase this time by simply editing some directives in php.ini.

First locate php.ini

root@host[~]# php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini

Get current session time out time

root@host[~]# grep -i session.gc_maxlifetime /usr/local/lib/php.ini
session.gc_maxlifetime = 14400
; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):

Edit php.ini

root@host [~]# vi /usr/local/lib/php.ini

Change value of session.gc_maxlifetime.

Restart httpd service!! its done

Leave a Reply

Your email address will not be published. Required fields are marked *