开发者

Change Cookie not working

开发者 https://www.devze.com 2023-02-17 19:07 出处:网络
I am using web browser and trying t开发者_如何转开发o change the cookies but the cookie remains null i donot know why

I am using web browser and trying t开发者_如何转开发o change the cookies but the cookie remains null i donot know why

any idea why it does not changes.i tried to monitor but observed that the method InternetSetCookie is not changing it,but the page that was navigated to renders and page changes cookie not my method

  [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
        public static extern bool InternetSetCookie(string lpszUrlName, string lbszCookieName, string lpszCookieData);
InternetSetCookie(textBox1.Text, null, "123");  
             webBrowser1.Navigate(textBox1.Text);


Don't pass null for the cookie name. And do pay attention to the return value, you should get false here because of the invalid name. Use throw new Win32Exception() so an error doesn't go unnoticed.

0

精彩评论

暂无评论...
验证码 换一张
取 消