Python aiohttp-设置cookie,然后重定向用户

Python aiohttp-设置cookie,然后重定向用户,python,aiohttp,Python,Aiohttp,我正在使用python aiohttp库编写一个web服务器 如何设置cookie,然后在一个响应中将用户重定向到另一个页面 可以使用aiohttp.web.HTTPSeeOther重定向用户,但我找不到将cookie附加到它的方法。只需设置响应的cookie值 import aiohttp response = aiohttp.web.HTTPSeeOther(<location>) response.cookies['test'] = '1' return response 导

我正在使用python aiohttp库编写一个web服务器

如何设置cookie,然后在一个响应中将用户重定向到另一个页面


可以使用
aiohttp.web.HTTPSeeOther重定向用户,但我找不到将cookie附加到它的方法。

只需设置响应的cookie值

import aiohttp
response = aiohttp.web.HTTPSeeOther(<location>)
response.cookies['test'] = '1'
return response
导入aiohttp
response=aiohttp.web.HTTPSeeOther()
响应.cookies['test']='1'
返回响应

除了我使用了
set\u cookie
函数而不是直接访问cookie字典之外,这一切都起到了作用。