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