Parsing connection info

I want to implement a program that tells me who is connected to my site
and to be able to push that information either into an array for
temporary analysis or maybe a file for later analysis. Theres multiple
ways to do this, I’m just looking for the most logical way. Any Ideas?

Thanks!