function admin_menu_session_count

nittany7 admin_menu.module admin_menu_session_count($timestamp = 0, $anonymous = TRUE)
cis7 admin_menu.module admin_menu_session_count($timestamp = 0, $anonymous = TRUE)
mooc7 admin_menu.module admin_menu_session_count($timestamp = 0, $anonymous = TRUE)

Counts how many users are active on the site.

Counts how many users have sessions which have been active since the specified time. Can count either anonymous sessions or authenticated sessions.

@todo There are mostly no anonymous sessions anymore. Split this into a separate module providing proper user statistics.

Parameters

$timestamp: A Unix timestamp. Users who have been active since this time will be counted. The default is 0, which counts all existing sessions.

$anonymous: TRUE counts only anonymous users. FALSE counts only authenticated users.

Return value

The number of users with sessions.

1 call to admin_menu_session_count()
admin_menu_get_user_count in modules/contrib/admin_menu/admin_menu.module
Return count of online anonymous/authenticated users.

File

modules/contrib/admin_menu/admin_menu.module, line 443
Render an administrative menu as a dropdown menu at the top of the window.

Code

function admin_menu_session_count($timestamp = 0, $anonymous = TRUE) {
  $query = db_select('sessions');
  $query->addExpression('COUNT(sid)', 'count');
  $query->condition('timestamp', $timestamp, '>=');
  $query->condition('uid', 0, $anonymous ? '=' : '>');
  return $query->execute()->fetchField();
}