Jump to content

How many users online in a web site?


co.ador

Recommended Posts

Is this what your looking for?

 

<?php
session_start(); 

define("MAX_IDLE_TIME", 3); 

function getOnlineUsers(){ 

if ( $directory_handle = opendir( session_save_path() ) ) { 
$count = 0; 
while ( false !== ( $file = readdir( $directory_handle ) ) ) { 
if($file != '.' && $file != '..'){ 
if(time()- fileatime(session_save_path() . '\\' . $file) < MAX_IDLE_TIME * 60) { 
$count++; 
} 
} 
closedir($directory_handle); 
return $count; 
} else { 
return false; 
} 
} 
?

 

Then to display the numbers online you would use

 

<?php
echo 'Number of online users: ' . getOnlineUsers() . '<br />';
?>

Jiblix where should I put the code since I don't have access to the file where x website is. What program should I use becuase I don't have access to that file in other words is not my website is any website I search with a browser.

 

is firebug ok then where should I save this file?

 

Thanks you!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.