depending on how your server stores sessions, you might be able to simply count the number of temp session files in the appropriate folder.
The better solution would be to store in a db table who's logged in; that way, you have both the number of users ( a simple count(*) will do that) and their names (like in the phpbuilder forums)