Add code to better manage the sessions and login.