session tracking, the database is now updated when a session starts and
ends. also, this function has moved to a separate file.