well, the sql standard way of doing it is:
select username from users where last_visit > current_date - interval '5 minutes'
You haven't told us what database you're using, so I can't do much more than this. if it's mysql, then it doesn't have standard time handling, so I don't know what you should do.
Chris