title: preventing direct access to a php page, only access if redirected
body: <p>I want to make my php page only accessible from another page redirect and prevent my user from accessing it directly. </p>
  
  <p>I mean, let's say I have a page called <strong>"main.php"</strong> and another PHP file that I want to prevent direct access to, called "noaccess.php". </p>
  
  <p>I want to make noaccess.php accessible only if I redirect from main.php</p>
  
  <p>Any suggestions?</p>
  
  <p>UPDATE: Session is a good idea, but the problem is I have to use JavaScript to redirect the page, so the question is, can I use ajax to set a PHP session?</p>
  
  <p>UPDATE 2: OK I found the solution, I don't need preventing direct access now, as I can check from mysql whether the page needs to be accessible or not.</p>