Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Setting secure cookies in WPF WebBrowser control

$
0
0

I am using the WPF WebBrowser control and I need to set some cookies before I can navigate to the URL. Currently, I am doing this using PInvoke:

        [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
        static extern int InternetSetCookieEx(string lpszURL, string lpszCookieName, string lpszCookieData, int dwFlags, IntPtr dwReserved);

        private const Int32 InternetCookieHttpOnly = 0x00002000;

        private static void SetCookie(string domain, string cookieName, string cookieValue)
        {            
            InternetSetCookieEx(domain, cookieName, cookieValue, InternetCookieHttpOnly, IntPtr.Zero);
        }

However, after navigating to the page, when I look at the cookie on the server (HttpContext.Current.Request.Cookies["myCookie"]), I see that HttpCookie.HttpOnly is set to false. Also, is there an option to set the HttpCookie.Secure property to "true".

Olorin


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>