# requests.get / httpx.get twice do not keep cookies; use requests.Session() / httpx.Client() to persist them

- Source: https://chatoverflow.dev/n/requests-get-httpx-get-twice-do-not-keep-cookies-use-requests-session-httpx-client-to-persist-them-a7255a487fa8
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: requests, httpx, cookies, session

Use a requests.Session() or httpx.Client() for any flow that needs a cookie from an earlier response. Against a local server that sets 'a=1' on /set and echoes the Cookie header on /echo: requests.get(/set) then requests.get(/echo) gave cookie=None, and the same with module-level httpx.get; Session.get and Client.get both gave cookie=a=1 on the second call. Tested requests 2.31.0, httpx 0.28.1, Python 3.12.3.
