Announcement

Collapse
No announcement yet.

How to clear cookies of the Unreal webbrowser?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to clear cookies of the Unreal webbrowser?

    Hi,
    I'm trying to use the webbrowser to create a login for facebook/google.
    However the cookies of this browser are not cleared after every session.
    This is how I create my browser
    Code:
    	FBrowserContextSettings browserContextSettings("myID");
    	browserContextSettings.bIgnoreCertificateErrors = true;
    	browserContextSettings.bPersistSessionCookies = false;
    	browserContextSettings.CookieStorageLocation = ServerEnvironment.BrowserCacheLocation;
    	FCreateBrowserWindowSettings webBrowserSettings;
    	webBrowserSettings.bUseTransparency = false;
    	webBrowserSettings.Context = browserContextSettings;
    
    	TSharedPtr<IWebBrowserWindow>  browserSP = IWebBrowserModule::Get().GetSingleton()->CreateBrowserWindow(webBrowserSettings);
    	TSharedPtr<SWebBrowser> browserWidget;
    	browserWidget = SAssignNew(browserWidget, SWebBrowser, browserSP)
    		.ViewportSize(FVector2D(GEngine->GameViewport->Viewport->GetSizeXY()))
    		.ShowControls(false)
    		.ShowAddressBar(false)
    		.OnUrlChanged(BIND_UOBJECT_DELEGATE(FOnTextChanged, OnBrowserUrlChanged));
    
    	GEngine->GameViewport->AddViewportWidgetContent(browserWidget.ToSharedRef());
    After I'm done I try to clear my cookies like this:
    Code:
    TSharedPtr<IWebBrowserCookieManager> cookieMan = IWebBrowserModule::Get().GetSingleton()->GetCookieManager();
    		cookieMan->DeleteCookies("", "");
    In the IWebBrowserCookieManager.h it says:
    Removes all matching cookies. Leave both URL and CookieName blank to delete the entire cookie database.
    The actual deletion will be scheduled on the browser IO thread, so the operation may not have completed when the function returns.
    Why are my cookies not cleared? Is this a bug?

    Any help would be appreciated.

    #2
    I have the same Issue

    Comment


      #3
      i've tryed it but didnĀ“t work: http://bit.ly/2Tby3rY
      Last edited by TheSubZer0; 03-01-2020, 09:46 PM.

      Comment


        #4
        This worked for me
        Code:
                
        IWebBrowserSingleton* WebBrowserSingleton = IWebBrowserModule::Get().GetSingleton();
        if (WebBrowserSingleton)
        {
          TSharedPtr<IWebBrowserCookieManager> CookieManager = WebBrowserSingleton->GetCookieManager();
           if (CookieManager.IsValid())
           {
            CookieManager->DeleteCookies();
           }
        }
        Note in DeleteCookies() also says
        The actual deletion will be scheduled on the browser IO thread, so the operation may not have completed when the function returns.
        So you may need some bind or delay before restart your browser.

        Comment

        Working...
        X