Cookies should be defined as an object, not an array.
Added autoRetryLogin and fixed failed login detection.