Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set cookies to WebView Control

I have cookies which taken from HttpWebRequest and I need to set these cookies to WebView control to another page.

How can I transfer these cookie to WebView control in windows 8.1 Store app?

like image 368
Pradeep devendran Avatar asked Feb 17 '14 12:02

Pradeep devendran


1 Answers

I got an answer on MSDN and it works well for me.

try
{
    Uri baseUri = new Uri(txtURI.Text);
    Windows.Web.Http.Filters.HttpBaseProtocolFilter filter = new Windows.Web.Http.Filters.HttpBaseProtocolFilter();
    Windows.Web.Http.HttpCookie cookie = new Windows.Web.Http.HttpCookie("cookieName", baseUri.Host, "/");
    cookie.Value = "cookieValue";
    filter.CookieManager.SetCookie(cookie, false);

    Windows.Web.Http.HttpRequestMessage httpRequestMessage = new Windows.Web.Http.HttpRequestMessage(Windows.Web.Http.HttpMethod.Get, baseUri);
    wvTest.NavigateWithHttpRequestMessage(httpRequestMessage);

}
catch (Exception oEx)
{
    // handle exception
}
like image 96
Pradeep devendran Avatar answered Nov 19 '22 07:11

Pradeep devendran