title: iOS cookie setting issue: safari and chrome
body: <p>I am debugging a cookie setting issue which reproduces in both Chrome and Safari on iOS only. Behold the following code block that works fine on Chrome/Safari/Firefox on OSX:</p>
  
  <pre><code>if (navigator.userAgent.indexOf('iPad') &gt; -1) {
      window.onpagehide = placeCookie
  } else {
      window.onbeforeunload = placeCookie
  }
  
  function placeCookie () {
      if (isAuthenticated()) {
  
          var cookie = 'cookieName=' + token + '; max-age=60'
  
          if (env === 'prod') {
              cookie += '; secure'
          }
  
          document.cookie = cookie
      }
  }
  </code></pre>
  
  <p>This code is meant to place a cookie when the window detects navigation. In our case, because it's angularjs, we're listening for a page reload, and we want that cookie to go with the request.</p>
  
  <p>Reload Code: <code>window.location.reload(true)</code></p>
  
  <p>To develop I'm using Charles Proxy to sniff the cookie, and also inspecting the cookies on a node server, because the safari inspector closes on page reload. When I reopen the inspector window, I can see the cookie is set in the browser, but neither the server or Charles sees the cookie. Here's a paste of the cookie from the safari inspector on iPad (which is not seen by server/charlesproxy):</p>
  
  <pre><code>Name        Value   Domain                      Path Expires 
  cookieName  token   localhost.charlesproxy.com  /    7/10/2017, 11:23:13 PM 39
  </code></pre>
  
  <p>When I step through it on other browsers, the cookie is visible everywhere.</p>
  
  <p>Does anyone know of any reason why iOS does not acknowledge the cookie? Is it possible the request is made on iOS before the cookie is placed? </p>
  
  <p>Please let me know if I can provide more info.</p>