Working log out and log in from database