I have an index page with three links as follws. When I click the first link (pageType1 in the example below), pageType1.php is run that first check if the user is logged in via cookie. If it is not then redirect the user to a login page. when a user submit login and password info on login page correctly, I want to display the info on pageType1.php
FILE: index.php
<a href="pageType1.php" target="_blank">PageType1</a>
<a href="pageType2.php" target="_blank">PageType2</a>
<a href="pageType3.php" target="_blank">PageType3</a>
FILE : pageType1.php
<?php
include"auth/auth_check_header.php";
print("pageType1 contents");
?>
FILE : pageType2.php
<?php
include"auth/auth_check_header.php";
print("pageType2 contents");
?>
FILE : pageType3.php
<?php
include"auth/auth_check_header.php";
print("pageType3 contents");
?>
FILE : auth/auth_check_header.php
$successful_login_url = ?????? //How to track this value.
if (!cookie_enabled)
{
//login page
header("location:$successful_login_url");
}
My question is how to track "$successful_login_url" value (Or what shoud I put as the value of this variable) in auth/auth_check_header.php
Note: I tried putting $_SESSION["referer"] as the value of "$successful_login_url" but it shows index.php after successful login. Thanks in advance
1) User try to access a pageType1.php
2) The user is redirected to the login.php which contains a form with the hidden field:
<input type="hidden" name="redirectTo" value="<?php echo $_SESSION["HTTP_REFERER"]?>" />
3) User type the login and when successfully authenticated:
$redirectTo = $_POST['redirectTo']
4) If $redirectTo
is not empty, then redirect, else redirect to a default page