Better way to set a cookie from a response

I’m setting a cookie by adding it to a response like this in a view:

response = redirect('index')
response.set_cookie('last_sender', post.sender)
return response

Is there a better way to do this?

I’m just curious, why are you asking the question?

What is making you think that this may not be the best way to do it? Is this not working for you for some reason?

I think I was just used to returning the response directly. Didn’t know if there was a more standard way of using a response. If you don’t see any way can be improved then all seems good.