how to get currently logged users in my website. I have a mysql table for maintain users.
I don’t know how to display names who are logged in.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Don’t use a
isOnlinefield as others suggested. Instead use alastSeenfield. You can put a timestamp in that field and update it either on every page view.If you want to go easy on your system, you can update every couple of minutes (with a variable
$lastUpdatein the user session containing the timestamp of the last update oflastSeen).To find “online” users, you can select all the users that were
lastSeenin the last X minutes, for instance 10 minutes.You can’t know an exact number of online users, because you can’t know if an user is looking at your page or he/she has already closed it. Anyway, a solution like this one is a good approximation.
Every hour or every day, depending on how many visitors you have, you can run a process to delete old entries.