true)]
static extern bool InternetGetCookieEx(
string url,
string cookieName,
5: StringBuilder cookieData,
6: ref int size,
7: Int32 dwFlags,
8: IntPtr lpReserved);
9:
const Int32 InternetCookieHttponly = 0x2000;
1: /// <summary>
2: /// Gets the URI cookie container.
3: /// </summary>
>The URI.</param>
5: /// <returns></returns>
static CookieContainer GetUriCookieContainer(Uri uri)
7: {
8: CookieContainer cookies = null;
9: // Determine the size of the cookie
10: int datasize = 8192 * 16;
new StringBuilder(datasize);
if (!InternetGetCookieEx(uri.ToString(), null, cookieData, ref datasize, InternetCookieHttponly, IntPtr.Zero))
13: {
if (datasize < 0)
return null;
to hold the cookie
new StringBuilder(datasize);
if (!InternetGetCookieEx(
19: uri.ToString(),
20: null, cookieData,
21: ref datasize,
22: InternetCookieHttponly,
23: IntPtr.Zero))
return null;
25: }
if (cookieData.Length > 0)
27: {
new CookieContainer();
';', ','));
30: }
return cookies;
32: }
const int INTERNET_OPTION_END_BROWSER_SESSION = 42;
2:
true)]
static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int lpdwBufferLength);
5:
static void ClearCookie()
7: {
8: InternetSetOption(IntPtr.Zero, INTERNET_OPTION_END_BROWSER_SESSION, IntPtr.Zero, 0);
9: }