Page 1 of 1

How does one edit a php.ini file?

Posted: Mon Aug 29, 2011 1:01 pm
by drayarms
Hello people, well the question couldn't be more explicit. I just learned how to view the php.ini configuration of my server using the phpinfo()script. But apparently it is a read only file. So how does one edit it? I am trying to extend session timeout. Thanks.

Re: How does one edit a php.ini file?

Posted: Mon Aug 29, 2011 1:17 pm
by greip
You can override the session timeout set in the php.ini file by doing something like this before calling session_start():

Code: Select all

ini_set(’session.gc_maxlifetime’, 8 * 60 * 60);
This would set the session timeout to eight hours.

Re: How does one edit a php.ini file?

Posted: Mon Aug 29, 2011 2:47 pm
by drayarms
@greip, would the changes be visible in the phpinfo() script? because I just changed the gc maxlife variable but i still see the old value in the phpinfo() read only file.

Re: How does one edit a php.ini file?

Posted: Mon Aug 29, 2011 3:54 pm
by twinedev
Some server configurations allow you to create a "site" php.ini file, where you just place a text file named php.ini in the root of the web directory. This method, if allowed should show changes in phpinfo()

If I remember right (I could be wrong, been a while since I actually looked at phpinfo() output), but I thought it showed both the server settings AND the runtime (this call) settings.

Sorry I couldn't help more, I'm used to working on my own servers where I can change the main php.ini file.

-Greg

Re: How does one edit a php.ini file?

Posted: Mon Aug 29, 2011 4:22 pm
by drayarms
thanks greg