Maybe you can use res.get_cookies here to avoid parsing the cookie by yourself