S
S
Sergey2020-08-29 21:46:53
Python
Sergey, 2020-08-29 21:46:53

How to transfer multiple cookies?

How to pass multiple cookies using the headers parameter
https://docs.aiohttp.org/en/stable/web_reference.h...

Passing one cookie works.

headers = {"Set-Cookie": "key=value"}
return web.Response(..., headers=headers)

It is impossible to transfer several, the names of the "Set-Cookie" keys are the same.
headers = {"Set-Cookie": "key=value", "Set-Cookie": "key=value"}
return web.Response(..., headers=headers)

This is the pycharm prompt

Parameter headers of aiohttp.web_response.Response.__init__ headers: Union[Mapping[Union[str, istr], str], CIMultiDict[str], CIMultiDict, CIMultiDictProxy[str], CIMultiDictProxy, None]
< Python 3.8 (pythonProject) >

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Yakushenko, 2020-08-30
@chelovekmuravei

So you can try:

response = web.Response()
response.set_cookie('name_1', 'value_1')
response.set_cookie('name_2', 'value_2')
return response

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question