Handle remote_auth way of logging in

Also, print better error messages when setting cookies fails.