Certain PHP values are configured from the backend of the server such as php ram, execution time/session time, upload limit, etc. Sometimes the session gets expired before php script execution, as a result, you will experience problems.
How to increase session timeout in php?
In order to make the changes, we need to modify php.ini file, for every user its location may differ but here we are going to modify primary php.ini file which will be available at : /usr/local/lib/php.ini
To modify local configuration file login as root,
somesh@server [~] # ssh [email protected]
Now we will first find the present value of session.gc_maxlifetime within php.ini file,
somesh@server [~] # grep session.gc_maxlifetime /usr/local/lib/php.ini
; setting session.gc_maxlifetime to 900
So here our present value for session.gc_maxlifetime. is 900 seconds, we are going to increase it to 1750 seconds.
somesh@server [~] # vi /usr/local/lub/php.ini
Now, navigate to session.gc_maxlifetime and increase the value to,
session.gc_maxlifetime= 1750
finally save the file ESC > :wq!
We made the required changes within the configuration file, to implement the changes we need to restart our web server,
somesh@server [~] # service nginx restart
somesh@server [~] # service httpd restart
Conclusion : So, in this article, we have learned how to increase session timeout in php? with easy steps. I hope this article helped you. If you like this article do not forget to join my newsletter for more such articles or if you are having any suggestions/feedback feel free to drop the comment below. Thank you 🙂
