MDanz Posted September 29, 2009 Share Posted September 29, 2009 session_start(); $username=$_SESSION['username']; i know how to show a button just for that user. e.g. if ($username) {} how do i show to other users a user is online?like on this forum or show a green circle. if($username ?????) { //show green circle } Link to comment https://forums.phpfreaks.com/topic/175874-user-online/ Share on other sites More sharing options...
eugeniu Posted September 29, 2009 Share Posted September 29, 2009 You'd need to either make a database of users that are online for reference or have a column in your users table that saves the last time a user was on your website. In your code that shows whether another user is online or not, you'd need to specify which user your talking about. $username = "eugeniu"; $username = // code to retrieve entry for "eugeniu" goes here if (time(); - $username['laston'] < 5*60) // 5 minutes till last on { echo "User is online."; } else { echo "User is not online."; } Hope that helped... Link to comment https://forums.phpfreaks.com/topic/175874-user-online/#findComment-926697 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.