You should store the session data in a seperate table.
example table design
sessid | arrivaltime | lastactive | userid
Keep updating the lastactive. And every 5mins if there is no activity for a URL get the userid, delete the row update the user table to no for online.