I am currently trying to setup a login script. I am trying to get it so when people use the login.php page it takes them back to the page they were viewing before they logged into the login.php page. For example if they were on testpage1.php then went to login.php logged in it would redirect them to testpage1.php.
So far I have followed some tutorials on SESSIONS with the following.
session_start();
$_SESSION['url'] = $_SERVER['REQUEST_URI'];
and on the login page I have
if(isset($_SESSION['url'])) {
$url = $_SESSION['url']; // holds url for last page visited.
$page->body ("$url");
}
I printed out the $url just to see the full redirect and I notice that it will only ever take it back to the login.php page rather than testpage1.php.
I know I could set a header and just forward the user to index.php or something similar but I think that would break the flow of working on the site.
Is there a way to get the redirect to go to the page before what would be captured using REQUEST_URI?