function session_api_cron

7.x-1.x session_api.module session_api_cron()

Implements hook_cron().

File

./session_api.module, line 116
Session API provides an interface for storing information in the session.

Code

function session_api_cron() {
  // Fetch list of outdated sids.
  $query = db_select('session_api', 'sap');
  $query->fields('sap', array('sid'));
  $query->condition('sap.timestamp', REQUEST_TIME - variable_get('session_api_cookie_expire_time', 2592000), '<');
  $outdated_sids = $query->execute()->fetchCol();

  if (!empty($outdated_sids)) {
    module_invoke_all('session_api_cleanup', $outdated_sids);
    db_delete('session_api')->condition('sid', $outdated_sids)->execute();
  }
}