OK, a little more detailed.
In the beginning of every script, where you check if user is logged (you have to do it anyway, don't you?) you insert a line in a table smth like
('jonnie', '2002-08-23 13:47:00')
(better if you have single record for each logged user with time he got a page last time)
If Jonnie logs off, you delete his record from table.
About auth: for example, at the moment Jonnie logs in, you generate unique random session id and store it in his cookies. And on the server you keep track which user got which session id.
you can generate such a random id combining rand, microtime & md5, for example, or some other way.