Firstly you can do this in one table.
i use a typically usertracking table like this
sessioncode|arrivetime|lastactive|currentfile
From there
sessioncode is the session name or PHPSESSID code etc.
arrivetime is when the session first started
Lastactive is what you will use to delete the session when not used for 5mins
current file, is just a thing i use if i want to display users on a page.
//deleting 5min old sessions that are not active.
function DelSession() {
mysql_query("DELETE FROM tablename WHERE lastactive <= '".time()."'");//assuming you are using time()
}
function UsersOnline() {
$query = mysql_query("SELECT * FROM tablename");
return mysql_num_rows($query);
}
Hope that helps you.