Keep users online for some amount of time

If we detect a user to be online now, we will consider him online for some amount of minutes. After this number of minutes we move its record from 'online' table to 'history' table - marking it as offline.