fastapi-sessions icon indicating copy to clipboard operation
fastapi-sessions copied to clipboard

RedirectResponse, HtmlResponse

Open disugiske opened this issue 3 years ago • 0 comments

Don't work with RedirectResponse, HtmlResponse, because you can't add cookie to response (example: response.set_cookie(key="fakesession", value="fake-cookie-session-value")). Solution: set cookie.attach_to_response(response, session) after response. Example:

response = templates.TemplateResponse("auth.html", {"request": request })
cookie.attach_to_response(response, session)
return response

Please add this info to instuction, i spent a few hours to figure it out.

disugiske avatar Aug 08 '22 13:08 disugiske