As Trott explained earlier, there is no such function in analytics. However, I give you a very old alternative. I wrote this in 2004, so it is deprecated, but basically works. In addition, it works without using any databases. Sometimes you need retro solutions like this :)
Live demo: kopli.pri.ee/stackoverflow/6976362.php
(You need to install 777 chmod for your current folder, so users.dat can be created automatically)
<?php $current_users_file = 'users.txt'; if (!file_exists($current_users_file)) fclose(fopen($current_users_file, "w")); $users = file($current_users_file); $found = false; $user_count = count($users); $fp = fopen($current_users_file, "w"); foreach($users as $user) { $user = explode("|", $user); if ($user[1]+300 < time()) { $user_count--; continue; } elseif ($user[0] == $REMOTE_ADDR) { $user[1] = time(); $found = true; } $user = trim(implode("|", $user))."\n"; fputs($fp, $user); } if (!$found) { fputs($fp, $REMOTE_ADDR."|".time()."\n"); $user_count++; } fclose($fp); echo 'Active users <b>' . $user_count . '</b>'; ?>
source share