public function SessionLimit::getUserActiveSessionCount in Session Limit 2.x
Same name and namespace in other branches
- 8 src/Services/SessionLimit.php \Drupal\session_limit\Services\SessionLimit::getUserActiveSessionCount()
Get the number of active sessions for a user.
Parameters
\Drupal\Core\Session\AccountInterface $account: The user to check on.
Return value
int The total number of active sessions for the given user
1 call to SessionLimit::getUserActiveSessionCount()
- SessionLimit::onKernelRequest in src/
Services/ SessionLimit.php - Event listener, on executing a Kernel request.
File
- src/
Services/ SessionLimit.php, line 395
Class
Namespace
Drupal\session_limit\ServicesCode
public function getUserActiveSessionCount(AccountInterface $account) {
$query = $this->database
->select('sessions', 's')
->distinct()
->fields('s', [
'sid',
])
->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
->countQuery()
->execute()
->fetchField();
}