$session_id] ); } return $retval_write !== false; } /** * Destroy a session. * * @param string $session_id Session Id. * * @return boolean */ function pandora_session_destroy($session_id) { $session_id = addslashes($session_id); $retval = (bool) db_process_sql_delete( 'tsessions_php', ['id_session' => $session_id] ); return $retval; } /** * Session garbage collector. * * @param integer $max_lifetime Max lifetime. * * @return boolean. */ function pandora_session_gc($max_lifetime=300) { global $config; if (isset($config['session_timeout'])) { $session_timeout = $config['session_timeout']; } else { // If $config doesn`t work ... $session_timeout = db_get_value( 'value', 'tconfig', 'token', 'session_timeout' ); } if (empty($session_timeout) === false) { if ($session_timeout == -1) { // The session expires in 10 years. $session_timeout = 315576000; } else { $session_timeout *= 60; } $max_lifetime = $session_timeout; } $time_limit = (time() - $max_lifetime); $retval = (bool) db_process_sql_delete( 'tsessions_php', [ 'last_active' => '<'.$time_limit, ] ); // Deleting cron and empty sessions. $sql = 'DELETE FROM tsessions_php WHERE data IS NULL'; db_process_sql($sql); return $retval; } // TODO: SAML should work with pandora session handlers. if (db_get_value('value', 'tconfig', 'token', 'auth') != 'saml') { $result_handler = session_set_save_handler( 'pandora_session_open', 'pandora_session_close', 'pandora_session_read', 'pandora_session_write', 'pandora_session_destroy', 'pandora_session_gc' ); }