title: Using $_SERVER['HTTP_REFERER'] With GET Variables
body: <p>I'm using PHP and I'd like to create an if statement that does something if the user came to the current page from the home page. So far, I've been using this code:</p>
  
  <pre><code>if(!in_array($_SERVER['HTTP_REFERER'], $validHomes){
  //do something}
  </code></pre>
  
  <p>The array $validHomes contains a couple different variations of index.php (without .php, without www.)</p>
  
  <p>This has been working fine but now I'd like the home page to have a GET variable sometimes which will have different values: www.example.com/index?var=5. $_SERVER['HTTP_REFERER'] treats URLs with GET variables that have different values as different from each other so I'm wondering if anyone has a suggestion for how to get around this? How can I trigger the if statement for a wide range of index URLs that contain GET variables with different values?</p>
  
  <p>Thanks a lot for any help.</p>