Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: Increasing the database connection lifetime.

Increasing the database connection lifetime: Difference between revisions

From MoodleDocs
No edit summary
m (category)
Line 3: Line 3:
I'm on a shared hosted server, and they told me that I was pushing the limits of their servers and must cease immediately. It was through a lot of searching did I find that using dbsessions was the way forward. It took me a while to understand the expiry timestamp in the MySQL database table, but then I found (after a lot of searching) that it counts in seconds from 1st Jan 1970 @ 12:00am.
I'm on a shared hosted server, and they told me that I was pushing the limits of their servers and must cease immediately. It was through a lot of searching did I find that using dbsessions was the way forward. It took me a while to understand the expiry timestamp in the MySQL database table, but then I found (after a lot of searching) that it counts in seconds from 1st Jan 1970 @ 12:00am.


It was only by doing this was I able to calculate the exact number of seconds that my dbsessions were lasting. This value was nowhere near the value chosen in the Admin->Variables. So I did more searching. I found that I needed to adjust session.gc_maxlifetime in php.ini. Because I'm on a shared server, I had to make this change via the .htaccess file. So I changed this number from 1440 seconds (25 minutes) to 14400 (4 hours) by adding this line:
It was only by doing this was I able to calculate the exact number of seconds that my dbsessions were lasting. This value was nowhere near the value chosen in the Admin >> Variables. So I did more searching. I found that I needed to adjust session.gc_maxlifetime in ''php.ini''. Because I'm on a shared server, I had to make this change via the ''.htaccess'' file. So I changed this number from 1440 seconds (25 minutes) to 14400 (4 hours) by adding this line:


php_value session.gc_maxlifetime "14400"
php_value session.gc_maxlifetime "14400"


This then gave me my 4 hour sessions (after checking against the MySQL table using a nifty Excel spreadsheet I quickly made).
This then gave me my 4 hour sessions (after checking against the MySQL table using a nifty Excel spreadsheet I quickly made).


[[Category:Administrator]]
[[Category:Performance]]
[[Category:Performance]]

Revision as of 16:13, 22 January 2006

Some advice copied from a posting by Kunal Kapoor:

I'm on a shared hosted server, and they told me that I was pushing the limits of their servers and must cease immediately. It was through a lot of searching did I find that using dbsessions was the way forward. It took me a while to understand the expiry timestamp in the MySQL database table, but then I found (after a lot of searching) that it counts in seconds from 1st Jan 1970 @ 12:00am.

It was only by doing this was I able to calculate the exact number of seconds that my dbsessions were lasting. This value was nowhere near the value chosen in the Admin >> Variables. So I did more searching. I found that I needed to adjust session.gc_maxlifetime in php.ini. Because I'm on a shared server, I had to make this change via the .htaccess file. So I changed this number from 1440 seconds (25 minutes) to 14400 (4 hours) by adding this line:

php_value session.gc_maxlifetime "14400"

This then gave me my 4 hour sessions (after checking against the MySQL table using a nifty Excel spreadsheet I quickly made).