title: PHP setcookie() function not working in Wordpress Template File
body: <p>I am using this code to set a cookie in a wordpress site. When I place this code in header.php, it works perfectly. But when I place this code in Separate template file, it does not work.
  Header File Code: (Before HTML Tag) </p>
  
  <pre><code>if (isset($_COOKIE['City'])) {
  setcookie('City', 0, -(3600*3600*3600));
  setcookie('City', "Edmonton2", 3600*3600*3600);
  }
  else {
  setcookie('City', "Edmonton", 3600*3600*3600);
  }
  </code></pre>
  
  <p>WP Template File Code: (Code is before the get_header() function)</p>
  
  <pre><code>&lt;?php 
  if (isset($_COOKIE['City'])) {
  setcookie('City', 0, -(3600*3600*3600));
  setcookie('City', "Edmonton2", 3600*3600*3600);
  }
  else {
  setcookie('City', "Edmonton", 3600*3600*3600);
  }
  ?&gt;
  &lt;?php
  /*
      Template Name: Community Landing Page
  */
  get_header(); ?&gt;
  </code></pre>
  
  <p>Any help would be highly appreciated.
  Thanks &amp; Regards</p>