Skip to content
Myr

Merge pull request #2713 from lukasgraf/master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Ian Cordasco · committed by Ian Cordasco · parents 3131439, 1bb9165 · Browse files · 2 files+20 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Docs: Clarify that method-level parameters are not persisted in sessions.

Diff stats

2 files+20 added−0 removed

  • other:+20 added−0 removed

2 files+20 added−0 removed

modified:docs/user/advanced.rst+18 added
43 unmodified lines
44Any dictionaries that you pass to a request method will be merged with the45session-level values that are set. The method-level parameters override session46parameters.4748Note, however, that method-level parameters will *not* be persisted across49requests, even if using a session. This example will only send the cookies50with the first request, but not the second::5152 s = requests.Session()53 r = s.get('http://httpbin.org/cookies', cookies={'from-my': 'browser'})54 print(r.text)55 # '{"cookies": {"from-my": "browser"}}'5657 r = s.get('http://httpbin.org/cookies')58 print(r.text)59 # '{"cookies": {}}'606162If you want to manually add cookies to your session, use the63:ref:`Cookie utility functions <api-cookies>` to manipulate64:attr:`Session.cookies <requests.Session.cookies>`.6566Sessions can also be used as context managers::6768 with requests.Session() as s:69 s.get('http://httpbin.org/cookies/set/sessioncookie/123456789')
794 unmodified lines
modified:docs/api.rst+2 added
79 unmodified lines
8081 >>> requests.codes['\o/']82 2008384.. _api-cookies:8586Cookies87~~~~~~~8889.. autofunction:: requests.utils.dict_from_cookiejar
178 unmodified lines