title: Cookies across subdomains and server - PHP and Apache2
body: <p>I run a website which has many different subdomains. We are introducing a new download server which is using a subdomain of the main domain. The way we normally check user information is with cross subdomain cookies etc but I know this wont work because they of the different server and I wondered what would be the best way of checking if the user is logged in etc on the main server. </p>
  
  <p>What I am wanting to do is the following</p>
  
  <p>Sub1.domain.tld = main server</p>
  
  <p>When you want to download a file, it will point you to the appropriate server where the files are stored </p>
  
  <p>Sub2.domain.tld = download server</p>
  
  <p>Is there any way to keep or check if the user was logged in please. </p>
  
  <p>The way we normally do it with cookies accross subdomains is </p>
  
  <pre><code>setcookie('LoginVariable1', $LoginVariable1, $expiretime, '/', '.domain.tld');
  setcookie('LoginVariable2', $LoginVariable2, $expiretime, '/', '.domain.tld');
  </code></pre>