You are here

function session_api_cron in Session API 6

Same name and namespace in other branches
  1. 5 session_api.module \session_api_cron()
  2. 7 session_api.module \session_api_cron()

Implementation of hook_cron().

File

./session_api.module, line 108
The Session API module provides a quick interface for storing information in the session.

Code

function session_api_cron() {

  // Fetch list of outdated sids.
  $result = db_query("SELECT sap.sid FROM {session_api} sap LEFT JOIN {sessions} s ON (sap.session_id = s.sid) WHERE s.sid IS NULL");
  $outdated_sids = array();
  while ($session = db_fetch_object($result)) {
    $outdated_sids[] = $session->sid;
  }
  if (!empty($outdated_sids)) {
    module_invoke_all('session_api_cleanup', $outdated_sids);
    db_query('DELETE FROM {session_api} WHERE sid IN (' . db_placeholders($outdated_sids, 'varchar') . ')');
  }
}