C#: Writing a CookieContainer to Disk and Loading Back In For Use

This problem was bugging me for ages, nothing I could find worked. I worked it out, so putting that information out into the world. Answer using BinaryFormatter: public static void WriteCookiesToDisk(string file, CookieContainer cookieJar) { using(Stream stream = File.Create(file)) { try { Console.Out.Write(“Writing cookies to disk… “); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, cookieJar); Console.Out.WriteLine(“Done.”); … Read more

Using CookieContainer with WebClient class

WebClient wb = new WebClient(); wb.Headers.Add(HttpRequestHeader.Cookie, “somecookie”); From Comments How do you format the name and value of the cookie in place of “somecookie” ? wb.Headers.Add(HttpRequestHeader.Cookie, “cookiename=cookievalue”); For multiple cookies: wb.Headers.Add(HttpRequestHeader.Cookie, “cookiename1=cookievalue1;” + “cookiename2=cookievalue2”);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)