When I want to redirect a user to a specific page behind a login page and they are not already logged in If they are able, they can redirect to the homepage where they can login
When they are logged in, they are redirected to a default address.
How can I remember that the user's original destination, before being redirected to the login page?
Edited with feedback
Thanks for the responses, what I did is the URL: domain.com/?url = $ _ SERVER [ "REQUEST_URI"]
, the user has detected the reason for not being logged in, then the GET request is set, so when the user is redirected to the login page, the user at which address Attempted to get it is set in the GET value. When the user logs in and authenticates, then I do a test to check whether there is a GET value, if it is, add it at the end of the URL address bar.
END EDIT
the current page URL The easiest way to add logic to the log page as a logic is:
... not logged in .... title ("location: loginpage.php? Url =". Urlencode ($ _ SERVER ["REQUEST_URI"])); (Note, for this, both scripts should be on the same domain. If they are on separate domains, you can see something like "http: // Use ". $ _ Server [" HTTP_HOST "]. $ _ Server [" REQUEST_URI "] )
And after logging in, redirect to that page:
< Pre> header ("location:". $ _ GET ["url"]);
Comments
Post a Comment