I have a website which has a web page containing list of logs. Now I usually give the link to access that page for some user eg : http://172.20.22.77/someapp/results.htm?id=45
Now when some user clicks on this .It would give him a login screen .But after login it does not go to the page that was intented . I am using sessions to implement the website and it has many pages, hence session is used to track the user browsing the page.
kindly let me know how can i redirect the URL being asked after user logs in .
Put the URL the user was accessing in the session before redirecting to the login page. The login page can then redirect back to that stored URL after authenticating the user.
On the page that needs logging in:
session_start();
$_SESSION['after_login'] = $_SERVER['REQUEST_URI'];
header("Location: login.php");
On the login page:
session_start();
if (user has entered correct username and password) {
header("Location: http://example.com" . $_SESSION['after_login']);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With