sess_count

Versions
5 – 6
sess_count($timestamp = 0, $anonymous = true)

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.

Code

includes/session.inc, line 116

<?php
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));
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.