public function SessionLimit::getUserActiveSessions in Session Limit 8
Same name and namespace in other branches
- 2.x src/Services/SessionLimit.php \Drupal\session_limit\Services\SessionLimit::getUserActiveSessions()
Get a list of active sessions for a user.
Parameters
\Drupal\Core\Session\AccountInterface $account: The user to check on.
Return value
array A list of session objects for the user.
File
- src/
Services/ SessionLimit.php, line 405
Class
Namespace
Drupal\session_limit\ServicesCode
public function getUserActiveSessions(AccountInterface $account) {
$query = $this->database
->select('sessions', 's')
->fields('s', [
'uid',
'sid',
'hostname',
'timestamp',
])
->condition('s.uid', $account
->id());
if ($this
->getMasqueradeIgnore()) {
// Masquerading sessions do not count.
$like = '%' . $this->database
->escapeLike('masquerading') . '%';
$query
->condition('s.session', $like, 'NOT LIKE');
}
/** @var \Drupal\Core\Database\Query\Select $query */
return $query
->execute()
->fetchAll();
}