title: Session variable being set on my PC but not on webhost's server
body: <p>I have the following code to check whether the client has javascript enabled in their browser:</p>
  
  <p>page.php:</p>
  
  <pre><code>&lt;?php
  session_start(); 
  if(isset($_SESSION['gocheck'])) {$gocheck = $_SESSION['gocheck'];} 
  else {$gocheck =   'no';}
  //echo $gocheck;
  if($gocheck=='no'){header ("Location: ./gocheck.php"); exit;}
  //Only reaches this line if gocheck.php has been run and Javascript is enabled.
  unset($_SESSION['gocheck']);
  //rest of page
  ?&gt;
  </code></pre>
  
  <p>gocheck.php:</p>
  
  <pre><code>&lt;?php
  session_start(); 
  $_SESSION['gocheck'] = 'yes';
  
  echo"
  &lt;!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd\"&gt;
  &lt;html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\"&gt;
  &lt;head&gt;
  &lt;script type=\"text/javascript\" language=\"JavaScript\"&gt;
  window.location.replace('page.php');
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  This website requires Javascript to be enabled in your browser. &lt;br /&gt;
  Please enable Javascript and try again.
  &lt;/body&gt;
  
  &lt;/html&gt;
  
  ";
  
  ?&gt;
  </code></pre>
  
  <p>So what should happen is the user is always redirected from page.php to gocheck.php, which sets the session variable $gocheck to 'yes' and directs back to page.php via Javascript. Because $gocheck is then equal to 'yes', page.php shouldn't direct back again tio gocheck.php.</p>
  
  <p>This worked fine on my PC (using WAMP), but when I upload the files to the webhost, it seems to get stuck in an infinite redirect loop between page.php and gocheck.php. Also, if I echo $gocheck in page.php, it returns 'no', so it seems as if for some reason the session variable $gocheck is not being set properly by gocheck.php.</p>
  
  <p>Could somebody please shed some light on this? Is there an error in my code? Is there something I need to change in php.ini on the webhost's server?</p>
  
  <p>Thanks!</p>
  
  <p>P.S. WAMP on my PC uses PHP v.5.3.0, but the webhost uses PHP v.5.2.12 - don't think this can be the problem though.</p>