I recently switch our Moodle to databased sessions in order to make it easily available to other queries. Instantly, user sessions would time out very quickly. I eventually found out that this is a Moodle bug, easily correctable by a few lines of code. My solution differed a little from the one in the Moodle bug tracker.
In /lib/setup.php line 305, insert the last three lines listed below.
} else { /// Database sessions
ini_set('session.save_handler', 'user');
// allow config to override PHP if using database sessions, too (Kassissieh)
if (!empty($CFG->sessiontimeout)) {
ini_set('session.gc_maxlifetime', $CFG->sessiontimeout);
}
Richard Kassissieh is Director of Technology and Learning Innovation at