PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have a members-only area on my web application where users have to login. Unregistered visitors will often try to access a "members-only" area and are presented with the message stating:
"You must first Login to access this area. Click here to login."
Once they go to the login page and login, how do I go about redirecting them back to the section they were at when they got the "restricted access -> go login" message like the one above? I would like for the login page to know where they had come from in my site and send them back to it after logging them in? Any ideas? Thanks!
if they are not logged in and try to view a restricted page then, using the $_SERVER array, set the page they are at into a session, redirect them to whatever, then when they login redirect to the site they where trying to goto from the $_SESSION and unset that $_SESSION var.
The script knows where it is when the "go login" message is shown. Store that information somewhere or pass it via the URL in some fashion to the login script. The login script can then, upon successful login redirect back to the URL referenced.