WebView. Cookies are not saved after exiting the application

the application immediately launches a webView with a link, the site is logged in by login or facebook, on mac os cookies are saved, on the device if you log in and kill the application, cookies are not saved, here is my code:

class WKWebViewController: BaseViewController {
    
    @IBOutlet weak var activityIndicatorView: NVActivityIndicatorView!
    @IBOutlet weak var webView: WKWebView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setupWebView()
        setup(link: "...")
    }
    
    func setup(link: String?) {
        showLoader()
        if let link = link {
            if let url = URL.init(string: link) {
                if !webView.isLoading {
                    hideLoader()
                    webView.load(URLRequest(url: url))
                }
            }
        }
    }
}


// MARK: - UIScrollViewDelegate
extension WKWebViewController: UIScrollViewDelegate {
    public func scrollViewWillBeginZooming(_ scrollView: UIScrollView, with view: UIView?) {
        scrollView.pinchGestureRecognizer?.isEnabled = false
    }
}

// MARK: - WKNavigationDelegate
extension WKWebViewController: WKNavigationDelegate {
    func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
        if navigationAction.targetFrame != nil {
            decisionHandler(.allow)
        } else {
            webView.load(navigationAction.request)
            decisionHandler(.cancel)
        }
    }
}

// MARK: - Private Methods
private extension WKWebViewController {
    
    func setupWebView() {
        webView.navigationDelegate = self
        webView.scrollView.delegate = self
        webView.allowsBackForwardNavigationGestures = true
        
        let source: String = "var meta = document.createElement('meta');" +
            "meta.name = 'viewport';" +
            "meta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';" +
            "var head = document.getElementsByTagName('head')[0];" +
            "head.appendChild(meta);"
        
        let script: WKUserScript = WKUserScript(source: source, injectionTime: .atDocumentEnd, forMainFrameOnly: true)
        webView.configuration.userContentController.addUserScript(script)
    }
}

the site also does not save cookies in the chrome browser, but saves in safari, unfortunately I have no right to share a link, what can be done on my part to force the application to have one session? Or is it a problem on the site

Terms of Service

Privacy Policy

Cookie Policy