1 Public StaticList<cookie>getallcookies (cookiecontainer cc)2 {3List<cookie> lstcookies =NewList<cookie>();4Hashtable table = (Hashtable) cc. GetType (). InvokeMember ("m_domaintable",5System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetField |6System.Reflection.BindingFlags.Instance,NULLCcNew Object[] { });7 foreach(ObjectPathListinchtable. Values)8 {9SortedList Lstcookiecol = (SortedList) pathlist.gettype (). InvokeMember ("m_list",TenSystem.Reflection.BindingFlags.NonPublic |System.Reflection.BindingFlags.GetField One| System.Reflection.BindingFlags.Instance,NULL, PathList,New Object[] { }); A foreach(Cookiecollection colcookiesinchlstcookiecol.values) - foreach(Cookie Cinchcolcookies) Lstcookies.add (c); - } the returnlstcookies; -}
Public Static BOOLStartie (Cookiecontainer cc,stringURL) { Try{List<Cookie> tempcookies =getallcookies (CC); foreach(Cookie IinchTempcookies.toarray ()) {InternetSetCookie (URL, i.name.tostring (), i.value.tostring ()+"; expires=sun,22-feb-2099 00:00:00 GMT"); } return true; } Catch{return false; } }
1 System.Diagnostics.Process.Start ("iexplore.exe", open URL);
Cookiecontainer convert to cookies and write to IE to remain logged in