title: cookies problem in PHP and AJAX
body: <p>I face some problem on my script that I use PHP and jquery to create login system.</p>
  
  <p>First I have PHP page contain form for login. when user click submit I use jquery to send data to server</p>
  
  <pre><code>$.post('server_login.php', {username:username.val(), password:password.val()}, function(data){
      alert(data);
  }); 
  </code></pre>
  
  <p>in server_login.php I have function to doing login user.</p>
  
  <pre><code>if($_POST['username']=='username' &amp;&amp; $_POST['password']=='1234'){
      $expire = time() + 60*60*24*30; //1 month expired.
      setcookie("user_id", $_POST['username'], $expire);
      echo true;
  }
  </code></pre>
  
  <p>and jquery alert "1" on my login page.</p>
  
  <p>the problem is when i refresh my website and retieve cookie, it not show me.</p>
  
  <pre><code>print_r($_COOKIE);
  </code></pre>
  
  <p>anything wrong?</p>