c# - Get HttpOnly cookies using HttpWebRequest -


i'm trying log in site programmatically using .net's httpwebrequest post method (code's written in c#). sent request login page, saved response cookies cookiecontainer, , made second httpwebrequest login details (email="myemail"&pass="mypassword") encoded , streamed request.

as didn't manage log in, checked cookies attached login request using fiddler, , discovered cookies flagged httponly. is, these cookies don't appear in response headers of previous requests (needless don't appear in script (html or js)).

i've done little research , imported wininet.dll library code explained here. here's code:

class cookiereader {     static int internet_cookie_httponly = 0x000020000;      [dllimport("wininet.dll", setlasterror = true)]      static extern bool internetgetcookieex(string url, string cookiename, stringbuilder cookiedata, ref int size, int flags, intptr preserved);      public static string gethttponly(string url)     {         int size = 1024;         stringbuilder builder = new stringbuilder(size);         if (internetgetcookieex(url, null, builder, ref size, internet_cookie_httponly, intptr.zero))         {             return builder.tostring();         }          else             return null;     } } 

i have 2 questions: firstly, internetgetcookiesex method returns false, url. since i'm new c#, first suspicion wrong code.

secondly, can't figure out way combine httpwebrequest post internetgetcookieex method. method gets url argument, without login details, , don't know how makes request (i suppose does).

i hope i've been clear... advice (so much) appreciated.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -