Skip to content

Coming from Webbrowser , Winforms DOM Document Access in Webview2 Clearing of Cookies Inprivate #176

Open
@igotbass

Description

@igotbass

Sorry if this has been discussed before, i cannot find the subject anywhere.

webbrowser.document object what is the equivalent in Webview2 ?
Can we access the DOM like we did with webbrowser control ?

How can all of the cookies and user data be cleared when the winform program is run ?
All of the cookies and data are still in the browser from prior sessions ?
with Webbrowser control we used wininet method

public static bool SupressCookiePersist()
{
// 3 = INTERNET_SUPPRESS_COOKIE_PERSIST
// 81 = INTERNET_OPTION_SUPPRESS_BEHAVIOR
return SetOption(81, 3);
}

    public static bool EndBrowserSession()
    {
        // 42 = INTERNET_OPTION_END_BROWSER_SESSION 
        return SetOption(42, null);
    }

    static bool SetOption(int settingCode, int? option)
    {
        IntPtr optionPtr = IntPtr.Zero;
        int size = 0;
        if (option.HasValue)
        {
            size = sizeof(int);
            optionPtr = Marshal.AllocCoTaskMem(size);
            Marshal.WriteInt32(optionPtr, option.Value);
        }

        bool success = InternetSetOption(0, settingCode, optionPtr, size);

        if (optionPtr != IntPtr.Zero) Marshal.Release(optionPtr);
        return success;
    }

This does not work with Webview2, is there any way to get a fresh browser session when the program is executed ????

Any help would be appreciated.

AB#28556146

Metadata

Metadata

Assignees

Labels

feature requestfeature requesttrackedWe are tracking this work internally.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions