Ajax/Php - Real Time Online User Counter

I want to have an Online user counter but something which performs real time. I mean when someone comes in, the counter updates, or when someone leaves the site, the counter decrease.

I can't find anything like this on net. Is there any script for this ?

Answers


You could probably keep a list of all sessions in a database and update the "online time" every time someone hits a page. Then check how many sessions were updated in the last x minutes. However, this won't be very real time: depending on the amount of minutes you defined it will be a little bit off.

Even Google Analytics (the new real time version) gets it wrong sometimes. Don't worry too much if you can't get it right either. ;-)


You should have a look to WebSocket. There is a lot of demos out there, mostly real-time chat application, you could hack something on it :) In my opinion, WebSocket seems a bit overhead in you case (you just want a number, no real two-sides communications) but it's the good way to do "real-time" apps.

Here are some links:


Need Your Help

The social group of Playframework?

java facebook playframework playframework-2.0 playframework-1.x

Is there any social group (ex: facebook group, fans page..etc) discussing on playframework ?

jquery change transform(rotateY)

jquery

$("#div").css("transform", "rotateY("+ '+='+90 +"deg)");

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.