title: PHP session not retained with AJAX calls
body: <p>I'm currently using the following JavaScript to send POST data to a website of mine:</p>
  
  <p><code>example1.com</code>:</p>
  
  <pre><code>function buttonFunction() {
      $.post("http://example2.com/core/file.php",{username:username, password:pword, coins:coins}, function(data) {
          // Stuff
      });
  }
  </code></pre>
  
  <p>Then within <code>file.php</code> on <code>example2.com</code> I have the following:</p>
  
  <pre><code>&lt;?php
  namespace Penguin;
  
  switch ($_SERVER['HTTP_ORIGIN']) {
      case 'http://example1.com': case 'https://example1.com':
      header('Access-Control-Allow-Origin: '.$_SERVER['HTTP_ORIGIN']);
      break;
  }
  
  date_default_timezone_set('America/New_York');
  error_reporting(0);
  
  session_start();
  if(isset($_SESSION['money_maker']) &amp;&amp; $_SESSION['money_maker'] != "") {
      echo "Cannot run.";
  } else {
      $_SESSION['money_maker'] = getmypid();
      echo $_SESSION['money_maker'];
      echo "Running.";
  }
  
  // REST OF THE PHP HERE
  
  ?&gt;
  </code></pre>
  
  <p>As one can see, I set a session (if one has not already been set), and then if the session is already set, the script will echo "Cannot run."</p>
  
  <p>However, the script never echos "Cannot run." even if I set the session on the previous AJAX run. In other words, the session is not being "saved." What's the issue? Any help?</p>