How to count number of online users? plz give me the code to display number of online users and total users.
THANKS in advance!!![]()
How to count number of online users? plz give me the code to display number of online users and total users.
THANKS in advance!!![]()
If you feel my post is usefull then click onto give me Reputation
http://sourceforge.net/projects/guri...3.zip/download
This is a HTML/PHP piece of programming that displays how many users are online. There are additional features like displaying the countries and etc.
Last edited by Awesomexr; 11-30-2009 at 02:19 PM.
Code is good but there are some configuration problems with database plz solve them
If you feel my post is usefull then click onto give me Reputation
I use a prefab counter: Histats.com has a lot. You can choose a counter (they have a lot, diferent counters... I'm sure at least one will look fine with your website template). And then customize what info is going to be displayed.
This could be very simple..
Each login creates a session (if you are using sessions i.e. you have session_start() at the top of the page)
You could then just count the amount of active sessions.
Simples!PHP Code:
/* Define how long the maximum amount of time the session can be inactive. */
define("MAX_IDLE_TIME", 3);
function countactiveusers(){
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 users online: ' . countactiveusers() . '<br />';
This method does not rely on using a database which is faster, but gets you no stats![]()
why you want to use your own database. I've seen many website which gives you the same service and that too without the need of any database in your site.
Your appreciation is extremely Important. Click on thebutton at the bottom left corner of my post.
The links for downloads are down, but you can easily find your own flag icons/images. Some of the script is outdated but you can get the main part and use trial and error for the rest.
http://forums.tutorialized.com/php-9...line-3776.html
Well really you need to create your own depending on your own circumstances. For instance where would you retrieve where the live? Via a database of your members or via the IP pool from wich they come from. All of these different solutions will work only for your circumstances. Also it is nice to be asked if it is okay for us to help you with a problem as apposed to be being told to fix it for you.