如何管理两个UIWebview的cookie?

时间:2017-12-01 10:09:08

标签: facebook url cookies webview session-cookies

我正在使用两个不同的Webview,使用FacebookWebview1登录'A'用户并使用FacebookWebview2登录'B'用户。

问题已解决:两个Webview都不同但是当我在WKFBView中使用用户'A'登录时,同一个用户会自动登录WKFBView1。(此问题使用Cookie解决)

新问题:当我从WKFBView1迁移到WKFBView时,我遇到了新问题,在WKFBView中使用了WKFBView1 cookie,而在WKFBView中自动记录了WKFBView1中记录的用户。

所以基本上使用了最后保存的cookie,但我想为不同的WKFBView保存不同的cookie。

我想要实现的目标:登录了不同用户的多个Webview。

单个用户表示我的网址链接(“https://www.facebook.com/”)。

@IBOutlet var WKFBView: WKWebView!
@IBOutlet var WKFBView1: WKWebView! 

 @IBAction func WebViewUserBtn1(_ sender: Any)
 {
   let myBlog = "https://www.facebook.com/login/"
   let processPool = WKProcessPool()
   let configuration1 = WKWebViewConfiguration()
   configuration1.processPool = processPool
   configuration1.websiteDataStore = WKWebsiteDataStore.nonPersistent()
   self.WKFBView= WKWebView(frame: self.view.frame, configuration: configuration1)
    let url = NSURL(string: myBlog)
    let request = URLRequest(url: url! as URL)
    WKFBView.navigationDelegate = self
    WKFBView.customUserAgent = "Safari/603.3.8"
    WKFBView.load(request)
    self.fbview.addSubview(WKFBView)
            }

        @IBAction func WebViewUserBtn2(_ sender: Any)
        {
          let myBlog = "https://www.facebook.com/login/"
          let processPool = WKProcessPool()
          let configuration1 = WKWebViewConfiguration()
          configuration1.processPool = processPool
          configuration1.websiteDataStore = WKWebsiteDataStore.nonPersistent()
          self.WKFBView1 = WKWebView(frame: self.view.frame, configuration: configuration1)
          let url = NSURL(string: myBlog)
          let request = URLRequest(url: url! as URL)
          WKFBView1.navigationDelegate = self
          WKFBView1.customUserAgent = "Safari/603.3.8"
          WKFBView1.load(request)
          self.fbview.addSubview(WKFBView1)
        }

0 个答案:

没有答案