Reputation: 137
I’m trying to install a cookie file from code on a client side machine. I can tell using the lovely IECookiesView tool, or the less lovely Notepad, that the cookie file contains multiple cookies of different names for the same domain.
However if I try (from C#) to set a cookie using InternetSetCookieEx, then I only appear to be able to set one cookie per domain.
Is there a way to set multiple cookies?
Upvotes: 1
Views: 548
Reputation: 137
I think the issue I had was that I had missed off the trailing semicolon on the first cookie. This meant that subsequent attempts to set cookies were ignored.
Upvotes: 0
Reputation: 57085
When using InternetSetCookieEx, you add one cookie at a time. You call it multiple times to add more than one cookie.
Having said that, InternetSetCookieEx only modifies the user's cookie store at the integrity level that it's run at; by default, Internet-zone tabs run at Low Integrity or AppContainer Integrity and as a consequence any cookies set by an application running at MediumIL will be ignored by that process.
For more information, see Q10 here: http://blogs.msdn.com/b/ieinternals/archive/2009/08/20/wininet-ie-cookie-internals-faq.aspx and read http://blogs.msdn.com/b/ieinternals/archive/2012/03/23/understanding-ie10-enhanced-protected-mode-network-security-addons-cookies-metro-desktop.aspx
Upvotes: 1