You are here

function sess_count in Drupal 5

Same name and namespace in other branches
  1. 6 includes/session.inc \sess_count()

Counts how many users have sessions. Can count either anonymous sessions, authenticated sessions, or both.

Parameters

int $timestamp: A Unix timestamp representing a point of time in the past. The default is 0, which counts all existing sessions.

int $anonymous: TRUE counts only anonymous users. FALSE counts only authenticated users. Any other value will return the count of both authenticated and anonymous users.

Return value

int The number of users with sessions.

2 calls to sess_count()
throttle_exit in modules/throttle/throttle.module
Implementation of hook_exit().
user_block in modules/user/user.module
Implementation of hook_block().

File

includes/session.inc, line 118
User session handling functions.

Code

function sess_count($timestamp = 0, $anonymous = true) {
  $query = $anonymous ? ' AND uid = 0' : ' AND uid > 0';
  return db_result(db_query('SELECT COUNT(sid) AS count FROM {sessions} WHERE timestamp >= %d' . $query, $timestamp));
}