Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aiohttp - Set a cookie and then redirect the user

Tags:

python

aiohttp

I am writing a web server using the python aiohttp library.

How do I set a cookie and then redirect the user to another page in one response?

It's possible to redirect the user with aiohttp.web.HTTPSeeOther, but I can't find a way to attach cookies to it.

like image 709
DXsmiley Avatar asked Feb 15 '17 05:02

DXsmiley


1 Answers

Just set cookie value of the response.

import aiohttp
response = aiohttp.web.HTTPSeeOther(<location>)
response.cookies['test'] = '1'
return response
like image 101
nmb.ten Avatar answered Sep 27 '22 02:09

nmb.ten