fix bug in login_and_retrieve_cookie