Session "Garbage Collection" function - deletes old sessions based on the 'databaseSession_lifetime' setting and the passed value (max lifetime is in minutes). Only used for database-driven sessions.


bool sessionGC (int $max_lifetime)

Parameter $max_lifetime

Expected type: Integer
Description: The maximum lifetime for sessions, in minutes (see notes)

Return value

Expected type: Boolean
Description: Returns true if the query was successful (regardless of how much was deleted). Dies with an error otherwise


  • Used as the 6th (and final) callback argument for session_set_save_handler
  • Only used when database-driven sessions are enabled
  • Checks the 'databaseSession_lifetime' setting
  • $max_lifetime is only used if the above setting is empty, greater than 1440 [24 hours] or less than or equal to $max_lifetime
  • Will not delete sessions less than an hour old, regardless of settings and max_lifetime value