WkWebView cookies setup issue

I am using the MSAL library for authentication, and after successful authentication, I am setting cookies for the WKWebView to run the application. However, it does not work.
I am using following code snippet for cookies setup :

DispatchQueue.main.async {
                var tokenCookieProperty: [HTTPCookiePropertyKey: Any] = [
                            HTTPCookiePropertyKey.domain: "*",
                            HTTPCookiePropertyKey.path: "/",
                            HTTPCookiePropertyKey.name: "cookieName",
                            HTTPCookiePropertyKey.value: result.session,
                            HTTPCookiePropertyKey.secure : "Yes" as String]

                let session: HTTPCookie! = HTTPCookie(properties: tokenCookieProperty)
                guard let bridgeWebController = self.bridge?.webView else {
                    print("Unable to get Capacitor bridge wkwebview")
                    completion(nil)
                    return
                }
                HTTPCookieStorage.shared.removeCookies(since: Date(timeIntervalSince1970: 0))
                HTTPCookieStorage.shared.setCookie(session)
                bridgeWebController.configuration.websiteDataStore.httpCookieStore.setCookie(session)
                bridgeWebController.reload()
            }

The key is to not use cookies :upside_down_face: See this post - Capacitor iOS / Cookie Authentication / capacitor/http - #10 by dallas

If you have to use cookies, why not use the Capacitor Cookie plugin?