Been reading a bit to find the answer with not too much luck.
I have a site where members can browse the site anonymously but some pages are restricted. I have the members redirected to a login page once they click a link that needs them to be logged in to view.
The problem I’m facing is I don’t know how to redirect the member to the page they were trying to get to once logged in.
They tried to to get to /profile.phtml , it sent them to /login.phtml , now when they log in, I want them to be sent to /profile.phtml because that’s where they clicked to get to. If they clicked /album.phtml, I want them to be sent to /album.phtml after login.
Can anyone help? Do I somehow store the URL in a session?
Much appreciated.
Just before making the
header("Location:")call to redirect, store the page they’re currently on in$_SESSION['redirect_to']. Upon successful login, make anotherheader()call to redirect back to the original page and unset the session variable so it doesn’t get accidentally reused anywhere.