Sometime we get link from a site, when we click the invitation link, it just send us to the index page for login(as we are not logged in in that site), when the login finishes, the site just redirect us to the link on which we clicked.
How this can be achieved in php?
Let’s say the “destination page” as called “
a.php” ; here’s a possible way of doing what you’re describing :a.phpfrom your browsera.phpdetects you are not logged inindex.php, with a parameter in the URL tellingindex.phpyou should be redirected toa.phpwhen logged-inheaderfunction, with aLocationheader that points to something likehttp://yoursite.com/index.php?destination=a.phpindex.php, you deal with the logging-in mecanism$_GET['destination']is stored (properly escaped, of course)index.php(i.e. itself) or another page ; doesn’t quite matter.destinationfield in the form’s data, you redirect the user to the corresponding pagedestinationfield, to make sure you are only accepting redirection to a “valid” page (the definition of “valid” can change — but can at least mean “a page on your site”)