Hello,
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

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.

can you help me in getting the time of server instead of users pc.

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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.