The error on that specific line indicates no cookies were stored.
Did you also install the JSON-For-mIRC script? You'll want that anyway to parse the json responses.
If you enter these commands do they produce real values? Don't post the actual cookie values here they could be used to access your account. You should be getting a lot of debug text in your current window while these are executing.
//echo -ag token: $cod.token
//echo -ag cookies: $cod.cookies
Hopefully you can get the login working. I added a new function to cache and print some stats: