title: WKWebView & Swift 3 - set cookie using evaluateJavaScript
body: <p>I have been trying to set a cookie for WKWebView using Swift 3 in order to pass a device token to a server.</p>
  
  <p>The code I've been trying to get working in order to set the cookie is as follows:</p>
  
  <pre><code>wkWebView.evaluateJavaScript("document.cookie='access_token=your token';domain='your domain';") { (data, error) -&gt; Void in
      print("data: \(data)")
      print("error2: \(error)")
      wkWebView.reload()
  }
  </code></pre>
  
  <p>However, I'm stuck here because this code produces the following error output:</p>
  
  <blockquote>
    <p>error2: Optional(Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo={WKJavaScriptExceptionLineNumber=0, WKJavaScriptExceptionMessage=SecurityError (DOM Exception 18): The operation is insecure., WKJavaScriptExceptionSourceURL=undefined, NSLocalizedDescription=A JavaScript exception occurred, WKJavaScriptExceptionColumnNumber=0})</p>
  </blockquote>