C # Delete WebBrowser control session

Source: Internet
Author: User

Reprint: http://www.hackdig.com/?02/hack-1464.htm

Because to make a similar account open the small auxiliary, but very pit dad found, in a WebBrowser, even if re-login, the display is still a previous account, try to empty the cookie is invalid, visual is the session problem, because the session information belongs to HttpOnly Cookies, so you cannot clear them directly.

Searched a circle, finally found the answer on the StackOverflow.

The HttpOnly cookie can be cleared with the help of WINAPI's InternetSetOption ().

Using system.runtime.interopservices;private const int internet_option_end_browser_session = 42; [DllImport ("Wininet.dll", SetLastError = True)]private static extern bool InternetSetOption (IntPtr hinternet, int Dwoption, IntPtr lpbuffer, int lpdwbufferlength);

and use it where you need to clear the session.

InternetSetOption (IntPtr.Zero, internet_option_end_browser_session, IntPtr.Zero, 0);

After jumping again, you will see that the session has been cleared.

C # Delete WebBrowser control session

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.