loginCookie method refactoring