how to set cookies in a webView for a windows 8 store app


  • I want to set cookies in a webView inside my app dynamically via the code for a particular user using the app. How can I achieve this? Please help

    Also, If the above is not possible is there a way in which I can pass cookie information as headers?

    For Windows Phone 7 I used to pass the cookie info as headers while WebBrowser.Navigate function. But I don't know if that can be replicated for a WebView in Windows 8. I am really stuck here :(

    Monday, November 19, 2012 1:29 PM

All replies

  • hey did you try creating cookies with javascript with invoke script on the webview control:

    webView.InvokeScript("eval", "document.cookie = \"name=mycookie\";");

    Can Bilgin
    Blog CompuSight

    • Proposed as answer by Jesse Jiang Wednesday, November 21, 2012 6:30 AM
    • Edited by Can BilginMVP Wednesday, November 21, 2012 7:56 AM
    • Marked as answer by Jesse Jiang Monday, November 26, 2012 9:19 AM
    • Unmarked as answer by Milan Aggarwal Monday, January 14, 2013 9:38 AM
    Tuesday, November 20, 2012 2:44 PM
  • Yes. It didn't work :(
    Monday, January 14, 2013 9:38 AM
  • I am trying to do the exact same thing and setting the auth cookie with an InvokeScriptAsync didn't work for me either.  In my case, I am successfully pulling html from a column in a SharePoint Online list and displaying it in a webview control.  Unfortunatley, the html has image tags that reference back to assets in SPO, and the image fails to load because the WebView doesn't pass the Auth token back with the request for the image.
    Tuesday, February 18, 2014 5:19 AM
  • A solution was posted here:


    Have not yet tried it myself.

    Got a bug or feature request? Tell me about it at http://connect.microsoft.com. This posting is provided "AS IS" with no warranties, and confers no rights.

    Monday, March 10, 2014 1:00 AM