title: How To Proceed File #2 Only When Accessed By File #1? I'm Using $_SESSION
body: <p>I have 2 files :</p>
  
  <pre><code>// test-redirect1.php
  &lt;?php
    session_start();
    $_SESSION['ctrl_access'] = '81938193813819381';
    // then some codes here...
  ?&gt;
  </code></pre>
  
  <p>and this file :</p>
  
  <pre><code>// test-redirect2.php
  &lt;?php
    session_start();
    if ($_SESSION['ctrl_access'] != '81938193813819381') {
      header( 'Location : goto-hell.php' );
    }
    // then some codes here...
  ?&gt;
  </code></pre>
  
  <p>I want to have <code>test-redirect2.php</code> only proceed when the referrer file is <code>test-redirect1.php</code>.</p>
  
  <p>I tried to use <code>$_SERVER["HTTP_REFERER"]</code> in <code>test-redirect2.php</code> but it doesn't show up if <code>test-redirect1.php</code> use <code>header( 'Location : some-file' );</code> as redirect.</p>
  
  <p>also, I don't want to show the <code>ctrl_access</code> variable to user. That's why I don't want to use POST / GET method.</p>
  
  <p>so, I decided to go with <code>$_SESSION</code>...</p>
  
  <p>but, the problem with the <code>$_SESSION</code> is, once I open <code>test-redirect1.php</code> on my browser, that variable is created then I can open <code>test-redirect2.php</code> and passing <code>if</code> condition.</p>
  
  <p>how to have <code>test-redirect2.php</code> only proceed when the referrer file is <code>test-redirect1.php</code>? </p>
  
  <p>thank you.</p>