Grabbing Cookies in Web Browser Control - WP7

后端 未结 5 711
Happy的楠姐
Happy的楠姐 2020-12-09 00:35

In order to log into a certain part of a website the users of my application require their cookie. To do this I need to grab it and pass it to url.

Does anyone know

5条回答
  •  一向
    一向 (楼主)
    2020-12-09 00:57

    // Ensure this is set to true BEFORE navigating to the page
    webBrowser1.IsScriptEnabled = true;
    
    // Once the page has loaded, you can read the cookie string
    string cookieString = webBrowser1.InvokeScript("eval", new string[] { "document.cookie;" }) as string;
    

    The cookieString variable will contain the full cookie for the document. You can then parse the string.

提交回复
热议问题