public function SessionLimit::getUserActiveSessions in Session Limit 2.x
Same name and namespace in other branches
- 8 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 422
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();
}