How can I get a list of all connected/logged in users? I would like to make a list of all logged in users accessible through the backend. The routes are created. It is only the request to retrieve the users that I would need. Is this data in the 'sessions' table? Thank you in advance for your help
You can try
// 3600s is one hour.
$uids = Drupal::database()-&gt;query('SELECT uid FROM sessions WHERE uid != 0 AND `timestamp` &gt;=:time',[':time'=&gt;(Drupal::time()-&gt;getCurrentTime()-3600)])-&gt;fetchCol();