0

Is there a way I can protect a page from being accessed unless it's from a particular referral URL? ie. if someone is on Page A and clicks a link to go to Page B, they would access it fine but if a person from anywhere else tries to access Page B, they get an error or possibly just redirected to Page A.

Thanks for the help

labli
  • 15
  • 1
  • 7
  • Check out this question: http://stackoverflow.com/questions/3528324/how-do-you-get-the-previous-url-in-javascript and this: http://stackoverflow.com/questions/4662110/how-to-get-the-previous-url-using-php – Bla... Aug 13 '14 at 02:02
  • hmm... create a query that updates if a page is being used. – kimbarcelona Aug 13 '14 at 02:02
  • laugh at any ones that says use the referrer and go down the sessions road –  Aug 13 '14 at 02:03

1 Answers1

1

How to do this properly

page a:

<?php
session_start();
$_SESSION['accssed_a']='yes';
//rest of page

page b:

<?php
session_start();
if($_SESSION['accssed_a']!='yes'){
header('Location: http://example.com/a.php');
exit();
}
//rest of page