aio-libs / aio-libs/aiohttp

ClientSession cookies does not work with IP

Open
#1,183 16 comments 4 reactions 0 assignees View on GitHub
enhancement need pull request
Dominant language
Python
Stars
16.5k
Forks
2.4k
Avg merge
17h 22m
Merged PRs (30d)
212

Description

## Long story short

I use `127.0.0.1` instead of `localhost` for development and wasted few hours before understand why my tests breaks :)

```
import asyncio
import aiohttp

async def main():
urls = [
'http://httpbin.org/cookies/set?test=ok',
'http://54.175.219.8/cookies/set?test=ok',
]
for url in urls:
with aiohttp.ClientSession() as s:
async with s.get(url) as r:
print(await r.json())
print(list(s.cookie_jar))

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
```
## Actual behaviour

```
{'cookies': {'test': 'ok'}}
[]
{'cookies': {}}
[]
```
## Your environment

Last stable release of aiohttp, linux

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.