Service to interface with sessions table?
You can make use of Dynamic Queries
instead of Database::getConnection()-&gt;query('SELECT expires_at FROM {sessions} s WHERE s.uid = :uid', [':uid' =&gt; $uid]);

You can do:

  // Create an object of type Select.
  $database = \Drupal::database();
  $query = $database-&gt;select('sessions', 's');
  // Add extra detail to this query object: a condition, fields and a range.
  $query-&gt;condition('s.uid', $uid, '=');
  $query-&gt;fields('s', ['expires_at']);
  $result = $query-&gt;execute();