it looks like $row['active'] is referring to a field in the database. it's probably there for the same reason that your new 'online' field would be there. you've got the right idea, you just need to add that new column.
if it was me, i would change the field to whatever the current time is at the same point in the script as session_register("myusername");
you can update the time again everytime they make a post, or interact with something.
to see how many people are online, just check for the ones that are within 20 minutes (or whatever) of the current time. then it wont matter if they dont log out.
but if they do actively log out, then change the time to something in the past, so they dont appear on the "within 20 minutes" list