I have a problem with simple authorization and loading an API script.
Upon authorization, the client receives several cookies, including the PHPSESSID cookie (in the browser).
I use the requests.post method with the form data for authorization:
r = requests.post(url, headers = self.headers, data = formData) self.cookies = requests.utils.dict_from_cookieja(r.cookies)
Headers are used only for custom User-Agent .
Authorization is 100% beautiful (there is a logout on the page). Later, I try to load data using allowed session cookies:
r = requests.post(url, files = files, data = formData, headers = self.headers, cookies = self.cookies)
But the site rejects the request. If we compare requests from script and google chrome (using Wireshark), there are no differences in the request body.
The only difference is that cookie 2 is sent by the request class, and google chrome sends 7 .
Refresh . Double flag, the first request receives 7 cookies. The post method just ignores half ...
source share