demo_requests_post_cookies.py:
import requests url = 'https://w3schools.com/python/demopage2.php' myobj = {'somekey': 'somevalue'} #use the 'cookies' parameter to send cookies to the server: x = requests.post(url, data = myobj, cookies = {"favcolor": "Red"}) print(x.text) #the 'demopage2.php' prints the value of the 'favcolor' cookie.
C:\Users\My Name>python demo_requests_post_cookies.py
<!DOCTYPE html>
<html>
<body>
<p>Favorite color: Red</p>
</body>
</html>