How to Show Connected Users Online
Moderator: General Moderators
-
vkhambalkar
- Forum Newbie
- Posts: 3
- Joined: Thu Nov 04, 2004 4:15 am
- Location: India
- Contact:
How to Show Connected Users Online
I am able to show connecte users online, separate table is there to kept the record of connected user, whenever users login i am making his online flag='Y', similarly wherenever he gets logout by clicking logout link, online flag becomes "N'. But wherenever someone closes hiw browser without clicking logut link he still show in connected user list, Anyone know how to do this ?
?>[/google]
?>[/google]
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
I check the activity of all users (anonymous and registered) and each time one user calls a page I log this in a table. As I log it I check I f any of those logas are older than for example 5 min. If so I delete them. Then I show all the different users (by IP for number and for anonymous and by username for registered). Each user interaction updates the db.
This can be a bit ressourceful.
This can be a bit ressourceful.
-
vkhambalkar
- Forum Newbie
- Posts: 3
- Joined: Thu Nov 04, 2004 4:15 am
- Location: India
- Contact:
-
vkhambalkar
- Forum Newbie
- Posts: 3
- Joined: Thu Nov 04, 2004 4:15 am
- Location: India
- Contact:
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
The trouble with this method is what happens when the browser javascript is disabled. I would go for the session/timeout solution.vkhambalkar wrote:i am using Unload event to open php page in which update is written to make online flag='N' & whenver new page from the same site is get loaded i have written update statement which again make online flag "Y". i works but sometimes create problem
I think the simplest thing to do would be to just have 2 values in the connected table - the id, and a timestamp. Everytime a person loads a page, update their timestamp in the connected table. Then, those users online are only those whose stamp is updated in the last 10, 20, 30, however many minutes. This will, however, create a bunch of overhead as there is an additional database call for each page load.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.