Is it possible to separate my changes to the php.ini into a different file, which overwrite the default settings.

E.g in my project.ini I wanted to overwrite the maxlifetime?

; Overwrite PHP settings required for Project

; 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 = 86400

I have seen some open source websites are packages with the php.ini inside. Is this a better approach?

1 Answer 1


You can set php.ini values manually in php with ini_set which overwrites the default values. Put this line at the top of every page (before session_start) or put it in a php file which is included everytime:

ini_set('session.gc_maxlifetime', 86400);

Check this page for more Information: PHP: ini_set - Manual

Additionally you can override ini values by using

php_value session.gc_maxlifetime 86400

in a .htaccess file which is described here: PHP: How to change configuration settings - Manual

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.