I'm running a 3.8.5 site with a fair bit of traffic. Because of some recent problems I noticed that the __session table is not being automatically tidied up.

The session lifetime is set to 1 hour (60 minutes), but when I realised there was a problem, there were sessions in the database which were over a month old. I've truncated the __session table four hours ago and it contains sessions which four hours old, so the garbage collections doesn't seem to be working correctly.

I can't be certain of the exact time-stamp of the the oldest session before I truncated the __session table, but I think it was 30th/31st of January 2018. This may be a coincidence, but it would correlate with the release of 3.8.4, which includes this pull request that modifies how sessions are cleaned up.

How can I make sure that database sessions older than 'session lifetime' are correctly deleted.

2 Answers 2


I believe changes were made to Joomla with the release of version 3.8.4, and that the session table will no longer be cleared if using 'Database' as the session handler.

See this page on Github.

The recommendation was to change the session handler from 'Database' to 'PHP'. To change this setting, log into the backend of the website. Access the System -> Global Configuration menu. Navigate to the System tab, and scroll down to the Sessions Settings heading. Select PHP from the drop-down list for the Session Handler option.

  • Note also that Joomla will provide a "patch" fix in 3.8.6 which is scheduled to be released next week (March 13, 2018). It will provide two fixes: (1) A new plugin that'll clear the session data during HTTP user requests (ie, it has the possibility to trigger a cleanup whenever any user requests a page). (2) Two new CLI scripts for clearing the session via command line, server scripts, and CRON jobs. You only need to use one or the other (though I guess you could use both, there is no need). In Joomla 4.0 the sessions/metadata architecture will be restructured so these might change or go away.
    – Drew G
    Commented Mar 7, 2018 at 14:19
  • (con't) Besides the Git page Adam already provided, github.com/joomla/joomla-cms/pull/19687 is also a key one to read.
    – Drew G
    Commented Mar 7, 2018 at 14:24

I've got a solution after reading the various pull requests on GitHub as pointed out above by Adam Gatt and Drew G.

In the summary of changes for github.com/joomla/joomla-cms/pull/19548, is says that database session data is cleared according to the schedule set by PHPs session probabilistic garbage collection. Checking my PHP configuration, I found that the session.gc_probability variable was set to zero, so session garbage collection would never run. Changing this value to 1 (with a divisor of 1000), has resulted in the sessions table being periodically cleaned out.

I'm not going to mark this answer as correct as I think Adam Gatt's answer, suggesting a switch away from the database as a session handler, is equally valid. Also Drew G's point about session handling changing in the upcoming Joomla release will probably make all of this irrelevant anyway.

  • 1
    I'd say go ahead and mark yours as correct (or Adam's). Otherwise stackexchange will periodically "bump" this question to the top of the "active" list (in an attempt to get it answered). Since this question will be irreverent soon let's get it closed/answered.
    – Drew G
    Commented Mar 7, 2018 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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