Refactor login state keeping mechanism.