Hello, I would like to see who is logged in on my website, but I'm experiencing some difficulties with following code. Let's say you and me are logged in both at the same time. Then you will see that only you are logged in and I will only see that I'm logged in. So we won't see of each other if we're logged in or not.. Altough I'm including the very same page,, <body> <? $user = ""; $user_passwords = array ( "login" => "pw", "jana" => "leet" ); // Clear the list of all members online and create an empty file $data_old = "online_data.php"; unlink($data_old); $data_new = fopen("online_data.php", "x+"); fclose($data_new); if(isset($_COOKIE["loginname"])){ $user = $HTTP_COOKIE_VARS["loginname"]; foreach($user_passwords as $key => $value){ if($user == "$key"){ // Get all the current users online and put in a string $att1 = "online_data.php"; $att2 = fopen ($att1, "rb"); $currententries = fread ($att2, filesize ($att1)); fclose ($att2); // Writes the users online to a file $fp = fopen("online_data.php", "w+"); fputs($fp, $currententries . "<p>" . $user . "</p></br>"); fclose($fp); } } } // When no members online if($user == ""){ $fp = fopen("online_data.php", "a"); fputs($fp, "<p>" . "Geen leden online,," . "</p><br/>"); fclose($fp); } ?> <p><? include("online_data.php"); ?></p> </body> Code (markup): I simply include this page in the webpage where I want it to be,, So I'm also including online_data.php which means that the members online (saved in online_data.php) should be the same on each computer, no matter if you're logged in or not.. I'm obviously not seeing something
Its because every time someone loads the page it deletes the online_data.php file and adds the user that is viewing it so it always displays you because you are the only one in the file