Jump to content

[fixed] Redirect After Login


danm68
 Share

Recommended Posts

Basic rundown:You visit a page that requires you to log in, you get redirected to login.php but the url of the page that redirected you is kept.After a successful login, you get redirected to the page you were trying to view earlier (which you may now see because you are logged in).Just wanted to get people's thoughts and methods on how they might accomplish this. I tried using $_SERVER['REFERER'] but when it redirects to login, the referer was blank and couldn't be used. Got some nice errors. It's like its not taking down the referer because of the header redirect. Does referer only work if the user clicks on a link?Thanks in advance.ps. Is there a problem with the session id being passed around through a cookie? What other methods are there?

Edited by Reiyan
Link to comment
Share on other sites

The normal way people do that is to append the return URL when you redirect. The referer won't be set, so when you do the redirect you need to tell the login page where to go back to. If you already have a session started you can use that also. Sending the session ID through a cookie is the normal way of doing it, you can see the cookie options here:http://www.php.net/manual/en/function.sess...okie-params.phpThe alternative is to append the session ID to each link so that it gets passed around through $_GET, which would be less secure than using a cookie.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...