0

I have this view:

async def accept_token(request):
    resp = web.Response(text='cookies were set')
    resp.set_cookie('name',
                    'value,
                    path='/',
                    max_age=3600)
    return resp

But I see cookies only in Response Cookies in Firefox, Cookie storage is empty. Setting CORS headers doesn't help

    resp.headers['Access-Control-Allow-Headers'] = '*'
    resp.headers['Access-Control-Allow-Credentials'] = 'true'
    resp.headers['Access-Control-Expose-Headers'] = 'X-Server-Header'
Dmitry Sazhnev
  • 383
  • 3
  • 16

1 Answers1

0

Problem can be with samesite cookie policy, you need to add SameSite=none to the cookie (Support appeared in aiohttp 3.7.0 release 24 Oct 2020)

So with aiohttp>=3.7.0 use next code

resp.set_cookie(... , samesite='none')
Ryabchenko Alexander
  • 10,057
  • 7
  • 56
  • 88