instead of storing a value like 1 in the database, you should use a unix timestamp instead. and either use a cron job or just make a call the a cleapup script everytime a person accesses the page that will remove the person from a database if the time is older than x minutes.
so if john smith comes on at 4pm, generate a timestamp using time(); if he leaves at 4:01 and jane doe comes on at 4:15, her visit will trigger a script and look at john's time, see its older than 5 minutes and delete him from the database. the value of a timestamp is # of seconds since the unix epoch in 1970. so arithmetic like this will calculate how long ago they visited the page.
$lifeTime = 300; //300 seconds, for 5 minutes
$visitTime = 1080780982; //timestamp as i write this post, which represents when a person requested the page.
if(time() - $visitTime >= 300) { //the time is older than 5 min
//delete the db entry
}
you will need to hold their ip in there as well and check if their ip isnt in there, add a new entry, otherwise update their time filed to represent the new time.