How to store cookies received from a request? How to store cookies received from a request? flask flask

How to store cookies received from a request?


You can't store the RequestsCookieJar, no, but if all you want are the names and values of the cookies, you can trivially convert the jar to a dictionary:

session['cookies'] = r.cookies.get_dict()

The RequestsCookieJar.get_dict() method also supports filtering by domain and path.

For future requests, the cookies parameter of requests.<METHOD>(...) calls accepts such a dictionary directly.