title: CORS Ajax calls create new session
body: <p>I would like to create a counter by using a session. But if I call the counter via Ajax the session is always reseted. Whats wrong?</p>
  
  <p>Here my PHP-File:</p>
  
  <pre><code>header('Access-Control-Allow-Origin: *');
  header('Access-Control-Allow-Methods: GET, POST');
  header("Access-Control-Allow-Credentials", "true");
  header('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');
  header($_SERVER["SERVER_PROTOCOL"]." 200 Ok");
  
           if( !isset( $_SESSION ) ) {
              session_start();
           };
  
  
          if (!isset($_SESSION['zaehler'])) {
            $_SESSION['zaehler'] = 1;
          } else {
            $_SESSION['zaehler']++;
          };
          echo "Zähler: ".$_SESSION['zaehler'];
  </code></pre>
  
  <p>my Jquery:</p>
  
  <pre><code>$.ajax({
     type: "GET",
     data: { whatever:'cool' },
     url: "http://www.huntinggrounds.de/test.php",
     xhrFields: { withCredentials: true }, //by trying this I will get a cors error by browser.
     crossDomain: true,
     success: function(response) {
         console.log(response);
     },
     beforeSend: function(xhr){
         xhr.withCredentials = true;
     }
  });
  </code></pre>
  
  <p>By calling the file <a href="http://www.huntinggrounds.de/test.php" rel="nofollow">test.php</a> it will counts up. By calling via ajax it always starts with 1. See <a href="http://huntinggrounds.de/glitch" rel="nofollow">Ajax Testfile</a> by just clicking in window and look at your console.</p>
  
  <p>Any Idea? THX for any hint in advance.</p>