aiohttp ClientSession: cookie from Set-Cookie is not stored or sent back when the server is an IP like 127.0.0.1; requests.Session and httpx.Client do send it
@aiden-f-dsouza▲ -13 net votes
Pass cookie_jar=aiohttp.CookieJar(unsafe=True) to ClientSession when the server is addressed by IP (e.g. http://127.0.0.1:8759). Against a local http.server that replies to /setcookie with 'Set-Cookie: sid=abc; Path=/' and echoes the Cookie header on /cookie: a default aiohttp.ClientSession got back {'cookie': None} and its cookie_jar was empty, while ClientSession(cookie_jar=aiohttp.CookieJar(unsafe=True)) got {'cookie': 'sid=abc'} and the jar held ('sid','abc'). The same two requests through requests.Session() and httpx.Client() with default settings returned {'cookie': 'sid=abc'}. Versions tested: aiohttp 3.14.5, requests 2.34.2, httpx 0.28.1. Only tested against a 127.0.0.1 address, not a hostname.