Series Catalogue
Web-based online statistics have been in a state of not very accurate! Basically there is no one way to actually count online users!
discuz! NT Online user function is to be done relatively good! Resources
His principle is roughly based on the user's operating interval to determine whether the user is online, can also be understood as the operation of the log, when the system scan log interval is too long will be understood as the user offline, so to constantly update the Operation table and operation table growing trouble, so must be scheduled to clear the Operation table, when the system starts to reset table data!
Think of MVC's own filters to record operations before or after executing the method! than discuz! NT operation may come in handy, though the idea is the same!
I personally think that it is not accurate to count the number of people online with the session and Applocation objects in the regular website. Users do not exit the user and close the site caused by the 20-minute buffer of the session is not accurate, but there is another idea in the system, because the system is usually in a large frame of the page, the user to the non-safe exit and shut down the system behavior can use JS to monitor, and through Ajax to update the number of users online , it should be possible!
I'm going to do it this way online, using applocaition to store online numbers, and online listings. Update online numbers and online listings when the page is closed, but consider the concerns of multiple system pages coexisting!
I don't know how people are now counting online numbers and online listings!
But the usual method is already clear, want the accurate statistic must pay more performance to consume!