CodeIgniter Forums
Showing currently online users... - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Showing currently online users... (/showthread.php?tid=2216)



Showing currently online users... - El Forum - 07-23-2007

[eluser]codelearn[/eluser]
Has anyone here written code that will output the current amount of users on the site (in say, the last minute or so).

I thought about using sessions but they seem to be wildly inaccurate. IP's? Ideas?

Thanks!


Showing currently online users... - El Forum - 07-25-2007

[eluser]Phil Sturgeon[/eluser]
You could use CI's db sessions and run a query on that?

Either that or do the normal

on pageload
insert userid, page, ip, date

then run a cron job every x often deleting old sessions? Could be run every 5 mins to delete all entries which should keep things FAIRLY accurate?


Showing currently online users... - El Forum - 07-25-2007

[eluser]codelearn[/eluser]
Hmm. I don't want to run a query on sessions because Google and other advertisers are always logging sessions in the table.

I think the page load idea is the easiest. Good call.


Showing currently online users... - El Forum - 07-25-2007

[eluser]Imkow@CN[/eluser]
im about to add that to my app. i used to write it without ci.
it's just going to need one table in db to trace the online users. you can even setup the table on pure memery, for the fastest responding time.