I have designed a website which let the users create account and use our services, my client asked me to design a page which will show all the online members at that time, the solution i have figured out is that i have create a column in my user table in database, when a user login it changes to 1 and when the user signs out it changes to 0. the problem is if the user close the browser and leave the site without signing out it still shows the user as online. I am using sessions in php please help me how to avoid this.

Thanks in advance

8 Years
Discussion Span
Last Post by scru

No, the column is to simple. Change it to store a timestamp of the last activity on the site. Everytime the user visits a page, the time stamp gets updated to the current time. When checking for what users are online, check for timestamps within the last 5, 10,15 (whatever your choice) minutes.


php function time() returns the server time in the timestamp format you need (or at least, easiest and probably best to work with in this case)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.