Interesting one from jpaddie, I think the cookie solution would only allow the page to check itself it is was posted back to the server. Reading between the lines it loks like you need a script that will run and tell you who is logged in now, you might run this at any time.
If your users need to authenticate to the site then you should be ok to have some kind of timestamp on the user record in the database which you can query. Each time any page is requested you would have to update the time stamp with the current time (you might even do this to implement a time out e.g. it's more than 20 mins since your last visit).
The session file stuff is interesting. Maybee just wordology here but sessions are held on 1 file per session basis not in one big file so you might be able to just look at the time stamps from an ls or dir to see who hasn't been here for 20 mins.
Now what I just said might not be true, you might have some custom session handler which does store all session info in a single file. You could even create your own session handler to hold session info in a database (good for web server farms) .
Also bear in mind that sessions are just that, you don't have to have any authentication to use them do your site could be all anonympus users, if you need to know the actual person who is logged in you will need to add that user name to the session details in ay case.
Hope this makes some sense !