I'll try to explain it as simple as possible: Each person has a unique (in most cases) IP provided by their isp/internet provider, this IP is recorded nearly on every site you access online to help indentify you, theirfore to track who is online its recorded along with the time accessed (and a few other browser powered values), and then the IPs recorded are all selected where the recorded time matches the current time/or close to which = total users/people online. Summary: It counts the IP's online which the time these IP's were online is the same as the current time (or not far off).
Ok correct me if wrong. The widget registers the IP and counts it into online poeple and if the in the next 1 minute the smae ip doesnt show up to another page it considers him to be offline.
Yep! Thats right Have a read here http://tutorialzine.com/2010/03/who-is-online-widget-php-mysql-jquery/
You can also use a cookie based method for doing this. I think it works equally well as the method others have mentioned about tracking active IP addresses on the site.
In addition to the ip method and cookie method, you could count session id's since each is unique, it's probably more accurate than an IP counter.