= ? AND session_closed_time == -1 LIMIT 1;'; $update_time = time() - $lifetime; foreach (cx_db_query($sql, $uid, $update_time) as $session) { return $session['session_user_id']; } return null; } cx_setup_register(1, function() { cx_db_exec('CREATE TABLE sessions ( session_id INTEGER PRIMARY KEY, session_uid STRING, session_user_id INTEGER, session_creation_time INTEGER, session_update_time INTEGER, session_closed_time INTEGER, FOREIGN KEY(session_user_id) REFERENCES users(user_id))'); });