Pyramid: set a cookie returning a HTTPFound
Probably it will not be the most common scenario, but if you want to save a cookie and make a redirection right away using HTTPFound, the cookie won't being saved. That's the fact.
It seems that
HTTPFound takes a own headers parameter, probably overwritting the one you used to set the cookie, so theorically nothing happened with your
response.set_cookie() unless you call
HTTPFound with the proper argument:
response.set_cookie('mycookie', value=myvalue) return HTTPFound(location=request.environ['HTTP_REFERER']), headers=response.headers)