title: Cookie Not Available Sitewide
body: <p>I'm having two issues with setting and retrieving cookies.</p>
  
  <ol>
  <li>Cookie gets loaded but can't be called until page is refreshed. Meaning that the cookie shows up in developer tools but not when trying to use its value on the page. The value does seem available to use on page after refreshing.</li>
  <li>Cookie is not available across entire domain and subdirectories. For example, if the user enters at <a href="http://example.com/sub/" rel="nofollow">http://example.com/sub/</a> the goes to <a href="http://example.com/" rel="nofollow">http://example.com/</a>, the cookie gets destroyed.</li>
  </ol>
  
  <p>Here's my code:</p>
  
  <pre><code>$ad_source = $_GET['source'];
  $date_of_expiry = time() + (86400 * 7);
  setcookie('ad_source',$ad_source,$date_of_expiry,'/');
  
  if ( $_COOKIE['ad_source'] == 'adwords_campaign_01' ) {
      echo '... do something';
  } elseif ( $_COOKIE['ad_source'] == 'adwords_campaign_02' ) {
      echo '... do something else';
  }
  </code></pre>
  
  <p>I'm trying to to show different information throughout entire site by determining what adwords campaign the user clicked in on.</p>
  
  <p>I don't usually use cookies and prefer to set a session, but in this case I want be able to track the source for a longer amount of time.</p>