728x90
๋ฐ์ํ
CookieContainer cookies = new CookieContainer();
cookies.Add(new Cookie("name1", "value1", "/", "www.domain1.com"));
cookies.Add(new Cookie("name2", "value2", "/", "www.domain2.com"));
Hashtable table = (Hashtable)cookies.GetType().InvokeMember("m_domainTable",
BindingFlags.NonPublic |
BindingFlags.GetField |
BindingFlags.Instance,
null,
cookies,
new object[] { });
foreach (var key in table.Keys)
{
foreach (Cookie cookie in cookies.GetCookies(new Uri(string.Format("http://{0}/", key.ToString().Substring(1,key.ToString().Length - 1)))))
{
Console.WriteLine("Name = {0} ; Value = {1} ; Domain = {2}", cookie.Name, cookie.Value, cookie.Domain);
}
}
์ถ์ฒ:
How to get cookies info inside of a CookieContainer? (All Of Them, Not For A Specific Domain)
Please see the code below: CookieContainer cookieJar = new CookieContainer(); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://www.google.com"); request.CookieContainer =
stackoverflow.com
728x90
๋ฐ์ํ
'๐จ๐ผโ๐ป๊ฐ๋ฐ > C#' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
C# - ๋๋๊ทธ ์ค ๋๋กญ(Drag & Drop) (0) | 2022.10.09 |
---|---|
C# - DateTime D-Day ๊ตฌํ๊ธฐ(TimeSpan) (0) | 2022.10.08 |
C# - RichTextBox ์๊น ์ง์ (1) | 2022.09.29 |
C# - ์ค์ ๊ฐ ์ ์ฅํ๊ณ ๋ถ๋ฌ์ค๊ธฐ (0) | 2022.09.26 |
C# - Application.Exit() ๋ช ๋ น์ด ์๋ ๊ฒฝ์ฐ (Environment.Exit(Environment.ExitCode)) (0) | 2022.09.26 |