Forum Moderators: coopster
So if the user is not logged in, the user will be directed to the login page.
Now the problem is, after logging in, the user goes to the menu page and the menu has different links to different webpages....
How can i directly take the user where he intended to go directly without logging in?
e.g.:
the website flow is: login page -> Menu -> page1
Current implementation:
If the user directly enters page1 url without logging in, the user is sent to the login page. After logging in, the user goes to menu page.
Desired implementation:
After entering the url for page1, the user should be taken to login page and after successful login, the user should be taken back to page1 instead of menu.
Please help me out with this....
Thanks!
if (!isset($_SESSION['username'])) {
if (isset($_SERVER['HTTP_REFERER'])) {
$ref = $_SERVER['HTTP_REFERER'];
} else {
$ref = '';
}
header("Location: index.php?r=".$ref);
}
--->
Then on the login page check if isset($_GET['r']) and that it's a valid URL using regex. If valid, store that value for use in the redirect after a successful login.