WebBrowserSingleton is undefined

Hey all!
I am trying to delete cookies in the browser that UE4 has. There’s a problem with this variable called WebBrowserSingleton. Visual Studio is saying that identifier is undefined. The browser is actually a UE4 plugin, so you won’t see it in a clean project if you haven’t enabled the plugin.

Here’s my cpp, you can see the variable on line 7.


#include "CookiesFunctionLibrary.h"
#include "Runtime\WebBrowser\Public\IWebBrowserSingleton.h"
#include "Runtime\WebBrowser\Public\WebBrowserModule.h"
#include "Runtime\WebBrowser\Public\IWebBrowserCookieManager.h"

void UCookiesFunctionLibrary::D
https:\/\/forums.unrealengine.com\/core\/image\/gif;base64
​eleteCookies() {
    IWebBrowserSingleton* WebBrowserSingleton = IWebBrowserModule::Get().GetSingleton();
    if (WebBrowserSingleton)
    {
        TSharedPtr<IWebBrowserCookieManager> CookieManager = WebBrowserSingleton->GetCookieManager();
        if (CookieManager.IsValid())
        {
            CookieManager->DeleteCookies();
        }
    }
}

Here’s my header file:


#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "CookiesFunctionLibrary.generated.h"

/**
*
*/
UCLASS()
class RISEOFASMODEUS_API UCookiesFunctionLibrary : public UBlueprintFunctionLibrary
{
    GENERATED_BODY()

        UFUNCTION(BlueprintCallable)
        static void DeleteCookies();

};

I’ve also tried adding the headers to my projectName.h file and also adding the “WebBrowser” module to the PublicDependencyModuleNames in my projectName.Build.cs but it didn’t seem to do anything. Any ideas what I’m missing? I’m new to this!

So I tried just using this as a blue print node and it worked even though visual studio said there was an error… weird but I guess it doesn’t matter if it works.

You definitely shouldn’t put the headers in your ProjectName.h file, not ever. You do need the module in your Build.cs file though.

Ignore intellisense errors and squiggles. They are useless and misleading. Just try compiling, you’ll get an error in the output window if it doesn’t work.