hi, i want to display the users that are online in my web-site (not the number of users but their nicknames. like this forum is displaying the online users in the bottom.). do you have any idea how to do that?
This could be done in a login.php page and a logout.php page and in mysql. so you would need to have a table with username password and whatever else you have but as another field you could create a field called logged and in that field it would say either "true" or "false" so when the user logs in in runs a mysql Insert into the table where username = whateverusername and it would place "true" into the field of logged and when user logs out it would do the same but place "false" into the field and then create a page called logged.php and you would run a mysql comand something like this: Select $username from table where logged == true Im not good with the exact mysql commands but you ge the basics of what I mean if not just PM me and I can work with you on getting this script to work -John
you have a nice idea but the problem is that the users are just closing the page. they don't click the "Logout" link. i want a script that can change the status of the logged in field from "true" to "false" in a inactive period of 20 minutes.
Just set the time for how long cookie should remain active something like this setcookie($name, $value, time()+3600); //expire in 1 hour
i want to delete the record from database after an inactive period of 20 minutes. not to expire a cookie.
The way I did it on one of my sites was with AJAX: you call your PHP script with a Javascript function every 30 seconds (for example), and the script gets the current user ID and sets it as "online" in the DB with the current timestamp. The same script also sets as "offline" (or just deletes them from the "online" table) users with a timestamp older than 30 seconds (or a minute)