Hello to all. I have application where users are able to login. I use database for users.
I want to get real-time currently logged users.For example if there are 5 online users and one of them close web browser, at the same moment online users to be 4.
If I use standard sessions the number of users will be decrease when session will ends (after 10-20 minutes)
I thing this problem will be resolved with using AJAX, but how :)

Thanks

Browser close event cannot determined accurately by code. Therefore you cannot re-count the online users if browser is closed by the user.

The javascript onbeforeunload event can be used to detect the browser close. But it will also get fired if the user click a link to go to another page. Also the onbeforeunload will not be supported some browsers other thatn IE.

Another solution?

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.