Reply to Re: Track Users Online with Sessions?

Your name:

Reply:


Posted by Barkster on 03/31/06 07:14

I found this and is what I'm looking for but no matter what I get '0'
for the count every time.

/* Start the session */
session_start();

/* Define how long the maximum amount of time the session can be
inactive. */
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 != '..'){
// Comment the 'if(...){' and '}' lines if you get a significant amount
of traffic
if(time()- fileatime(session_save_path() . '\\' . $file) <
MAX_IDLE_TIME * 60) {
$count++;
}
}
closedir($directory_handle);

return $count;

} else {
return false;
}

}

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация