N/APosted on - 10/19/2014
Is it possible to disallow direct access to a PHP file and allow the access only if it's redirected from other PHP file? For example, access to loading.php should be only allowed if it's redirected from example.php page. How how can I do that? I hope you understand what I mean. If not, please ask me, and I will try to explain better.
Allow access to php file only if redirected
You can use $_SESSION in PHP.
if (isset($_SESSION['userid']) /* or something like that */)
// do whateven you need to do and set up $_SESSION variables
// for example get the user entered info here
// This is how you set session variables
$_SESSION['userid'] = ...;
// Then after you did the registration part or something else you wanted to do
// You can redirect the user to any page you want
Every time user tries to enter the
updateprofile.php right away, he or she will be redirected to login after they have logged out because the session is destroyed.