Think I've found a way:
code:
[DllImport("ieframe.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool IESetProtectedModeCookie(string url, string name, string data, int flags);
public static bool SetWinINETCookieString()
{
return IESetProtectedModeCookie("http://url.co.uk", "name", "data=blah; expires = Sat,01-Jan-2012 00:00:00 GMT; path=/", 0x10);
}
Slim pickings on Google to say the least, that shit has taken me 2 hours!
I'm not even convinced it's correct, AND it returns false but it seems to work here on IE9. Just need to test it on IE8.
The final product which creates cookies in both protected and unprotected mode, regardless of whether the user has visited the site before or not. Tested on IE8 and IE9:
code:
class Program
{
[DllImport("ieframe.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool IESetProtectedModeCookie(string url, string name, string data, int flags);
[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool InternetSetCookie(string url, string name, string data);
static void Main(string[] args)
{
IESetProtectedModeCookie("http://url.co.uk", "Name", "data; expires = Sat,01-Jan-2012 00:00:00 GMT; path=/", 0);
IESetProtectedModeCookie("http://url.co.uk", "Name", "data; expires = Sat,01-Jan-2012 00:00:00 GMT; path=/", 0x10);
InternetSetCookie("http://url.co.uk", "Name", "data; expires = Sat,01-Jan-2012 00:00:00 GMT; path=/");
}
}
Just need to make the date dynamic.
EDITED: 24 Sep 2011 16:20 by PILOTDAN