You could try IESetProtectedModeCookie
if you are interacting with low-integrity browser controls. This still has limitations as noted in this cookie FAQ:
IE10+ on Windows 8+ introduced Enhanced Protected Mode which uses
AppContainers (rather than Integrity Levels) for isolation. EPM does
not offer an API for interacting with cookies;
IESetProtectedModeCookie will not set the cookie inside an
AppContainer.
Creating AppContainers is not documented so I assume your process is not running in a AppContainer?
This newsgroup thread confirms that you cannot set a cookie in the headers:
In case anybody is interested, I went through Microsoft support to
find out more about this. Their answer: what I want to do is not
supported. The 'headers' argument to Navigate/Navigate2 CANNOT be
used to set cookies.
I'm guessing that refreshing the page after put_cookie
is unacceptable?