title: jquery and php ajax sessions
body: <p><strong>Here is what I do:</strong></p>
  
  <p>my login form is on www.mysite.com/login.html: (subdomain www!)</p>
  
  <pre><code> function authenticate(userName, password) {
      $.ajax
      ({
          type: "POST",
          //the url where you want to sent the userName and password to
          url: 'http://server.mysite.com/ajax/auth.php',
          dataType: 'json',
          async: false,
          cache: false,
          data: 'vardas='+userName+'&amp;psw='+password,
          success: function (data) {
                  {
                      window.location.replace('/main.html');
                  }
          }
      })
      }
  </code></pre>
  
  <p>Here is my ajax/auth.php:</p>
  
  <pre><code>header('Content-type: application/json');
  header ("Access-Control-Allow-Origin: http://www.mysite.com");
  header('Expires: ' . gmdate('r', 0));
  
  session_start();
  $_SESSION["ok"] = 1111; &lt;- test value
  </code></pre>
  
  <p>Here is main.php:</p>
  
  <pre><code>&lt;script&gt;
    $(function() {
      $('#home').load('http://server.mysite.com/ajax/loader.php', function() {
      })
    });
  &lt;/script&gt;
  &lt;div id=home&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Here is my ajax/loader.php :)</p>
  
  <pre><code>&lt;?
      header ("Access-Control-Allow-Origin: http://www.mysite.com");
      header('Expires: ' . gmdate('r', 0));
  
      session_start();
  
      var_dump ($_SESSION); &lt;---- OUTPUT IS (0) EMPTY!! Why ?
  ?&gt;
  </code></pre>
  
  <p><strong>Why this does'nt work? I always get $_SESSION empty.</strong></p>