Jump to content

[fixed] Redirect After Login


danm68

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?

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...