title: Session do not work on ajaxRequest [How to count ajax-request with session variable]
body: <p>I have the following PHP code which counts every access to the page. If I call the side direct it counts certain. If I make a Ajax call it starts always again with 1.</p>
  
  <pre><code>&lt;?php
  session_start();    
  header('Access-Control-Allow-Origin: *');
  
          if (!isset($_SESSION['zaehler'])) {
            $_SESSION['zaehler'] = 1;
          } else {
            $_SESSION['zaehler']++;
          }
  echo  $_SESSION['zaehler'];
  
  
  ?&gt;
  </code></pre>
  
  <p>I understand that an ajax call is the same like an direct call by reading this: <a href="https://stackoverflow.com/questions/676846/do-ajax-requests-retain-php-session-info">Do AJAX requests retain PHP Session info?</a>
  How can I count each ajaxCall as long as the side is open?</p>
  
  <p>I'm doing a simple jquery ajaxCall:</p>
  
  <pre><code>    $.get( "http://www.huntinggrounds.de/aa.php", function( data ) {
           console.log( "dataResponse: ", data );
      }) .fail(function(jqXHR, textStatus ) {
          console.log( "error",textStatus);
         })
         .always(function() {
          console.log( "finished" );
         });
  </code></pre>
  
  <p>I made test-files, <a href="http://huntinggrounds.de/aa.html" rel="nofollow noreferrer">testfile.html</a>, just a black screen. Click on desktop and see the counter in your console the php-file is <a href="http://huntinggrounds.de/aa.php" rel="nofollow noreferrer">here</a>.</p>