Yes very much possible.

What you can do is there should be start timer when user is logged in and and in each page load or anything that timer makes an entry like end timer and the final entry would mean amount of time he was online.