got a link in a.php to b.php there is a link in b.php to a third party page( like 'paypal')
if user click back from third party page it take you to b.php
want to avoid that and skip to a.php
tried http_referer which is always a.php
its similar to a typical shopping cart. user add items to cart in a.php then click 'payment' which takes them to b.php, which is T&C and a checkbox to agree to it.
never want user to directly browse b.php
Assign session in php A
$_SESSION['hi'] = 1;
And check session if it is available in php B then remove it at the end of your code
if(isset($_SESSION['hi'])){
//your code
unset($_SESSION['hi']);
}else{
//redirect somewhere
}