how can I know if user is logged in <p>Im using simple mechanizm in which after login in my database there is new row inserted with userId and expiresDate columns. Everything would be ok but how can I know if user leaves website, closes browser and so on ?</p> <p>Secondly how can I make his sessionlonger if he is viewing different pages on the site. Should I all the time make updates on the database ?</p> <p>what are common aptterns ?</p> <p>It is im,portant for me because on the liveChat I need to know which users are online so that client can chat with them</p>