raising httpfound can't set cookies properly

53 views
Skip to first unread message

Gelin Yan

unread,
May 13, 2021, 11:42:09 PM5/13/21
to aio-libs
Hi All

    I tried to redirect a link with cookies without success.
 
 os: Linux

python: 3.8.9

aiohttp: 3.7.4.post0
 
   pseudo codes are here:

      f = web.HTTPFound(request.app.router['index'].url_for())
     f.set_cookie('abc', 'ddd')
     raise f

     async def index(request: web.Request):
           print(request.cookies)
          resp = aiohttp_jinja2.render_template('web_app/index.html', request, {})
          return resp
    
  request object on index handler didn't have the cookie 'abc'

  however When I use "return f" like following
      
     f = web.HTTPFound(request.app.router['index'].url_for())
     f.set_cookie('abc', 'ddd')
     return f
 
   It just works.

      I want to know what happened.

Regards

gelin yan
      
Reply all
Reply to author
Forward
0 new messages