Cookie not loading in WKWebView

I'm currently working on a web view that takes a js plugin via .evaluateJavaScript(). The js script will read a cookie and send it along with requests to a url that is different from the url of the web view.

I have this cookie in the URLSession.shared.configuration.httpCookieStorage, and initialized the webView with the default init() without passing any parameters. However, upon injecting the js, the required cookies does not appear in the webpage's storage (using safari inspector). I tried to do an output of the webView.configuration.websiteDataStore.httpCookieStore.getAllCookies(), and the result shows the specific cookie is there. Hence I'm confused about it. Anyone could help me with that would be greatly appreciated.

Sandbox.

Would you mind elaborating it a bit more? I tried to run it on real devices and it doesn't work either.

Cookie not loading in WKWebView
 
 
Q