I apologize if I am getting too basic, here, since i don't know your knowledge level.
The only real way to do this is to use sessions. Since http is a stateless protocol, a 'connection' is a meaningless thing. Someone is connected only as long as they are downloading a page, but to the server, once they have downloaded the page and are sitting there reading it for 5 minutes, they are disconnected.
The sessions solution is a workaround that saves a unique identifier as a cookie to each browser visiting the site, which the server tracks, saving information on the server-side, thus giving you the ability to know how long a specific person has been moving around in your site. You can specify timeouts for inactivity, etc... This is how ASP maintains that information on the server side. Not being too familiar with ASP, I don't know how much the programmer is shielded from the implementation of sessions.
PHP4 has sessions built in, and you can track users with a few simple functions. For sessions on PHP3, you need a few additional classes that have been put together called PHPlib, available at
[sig][/sig]