Recently, I needed to test some functionalities in our web applications that require the inbound request to be populated with specific key/value pairs in a cookie.  It turns out that with C#, it wasn’t that bad.  Actually, it was surprisingly easy.  What you want to do is use WinInet’s function and call it in your application:

[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool InternetSetCookie(string lpszUrlName, string lpszCookieName, string lpszCookieData);

From there, you create your cookie instances:

Cookie temp1 = new Cookie("KEY1", "VALUE1", "/Path/To/My/App", "/");
Cookie temp2 = new Cookie("KEY2", "VALUE2", "/Path/To/My/App", "/");

Add them to your (soon to be instantiated) IE Browser session:

InternetSetCookie("", null, temp1.ToString() + "; expires = Sun, 01-Jan-2013 00:00:00 GMT");
InternetSetCookie("", null, temp2.ToString() + "; expires = Sun, 01-Jan-2013 00:00:00 GMT");

Call your web browser within C# and enjoy the results: