Modified login to try logging in first before detecting if online.