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?