title: Cookies not set using PHP setcookie function
body: <p>I'm using the <code>setcookie</code> php function to set some cookies in my browser.
  I try to set cookies in my php code and then I check it using <code>print_r($_COOKIE)</code>.
  Cookies are not displayed, however if I try to set cookie in another file they
  will be displayed correctly.</p>
  
  <pre class="lang-php prettyprint-override"><code>if (isset($_POST['username']) &amp;&amp; isset($_POST['password']))
  {
      global $username,$password;
      $username = $_POST['username'];
      $password = sha1($_POST['password']);
      setcookie('username', $username, time()+3600); //cookie not set
      setcookie('password', $password, time()+3600); //cookie not set
      $database = connect_to_database($db_path);
      $result = $database-&gt;query("SELECT * FROM users WHERE username = '$username' AND password = '$password'");
      while (true)
      {
          $response = $result-&gt;fetchArray(SQLITE3_ASSOC);
          if (!$response)
          {
              unset($_COOKIE['username']);
              unset($_COOKIE['password']);
              break;
          }
          if (($response['username'] == $username) &amp;&amp; $response['password'] == $password)
          {
              header("location: ../index.php");
          }
      }
  
  }
  </code></pre>
  
  <p>I expected cookies to be set, but using <code>print_r($_COOKIE);</code> returns me <code>array()</code></p>
  
  <h2>Notes</h2>
  
  <ul>
  <li>Cookies are allowd in my browser settings</li>
  <li><code>$_POST['username']</code> &amp; <code>$_POST['password']</code> sent to this page via form in another page</li>
  <li><code>$_POST['username']</code> &amp; <code>$_POST['password']</code> are set with true value.</li>
  </ul>