a very common question...
i asked this question about 2 months ago...
try search "users online" you'll get lots of answer..!
but i'll tell you what i've done..!
i have a session table in mySQL database..!
when each new session is created i add that in the database..!
inside the session table it has
- session_id
- current_page
- user_id
- time
if you store all this infomation in the database... they you should be able to use a simple SQL statment to count up the users
"SELECT count(*) FROM session WHERE time > ".date() - 600 "
something like that...