Jump to content

redirect after sucsessful login


phpfan101

Recommended Posts

When someone is linked to a page that is availible only to those who are logged in, i redirect them to login.php, letting them either login, or register. so after that, it brings them to there main page on the site, so the link they originally came for, isnt even seen unless they link again, or go back a few times...

 

So, i was on Facebook the other day, and noticed that they do exactly what im looking for, so after there login, they are directed straight to what they were originally linked to...

 

I'm hoping someone gets what i mean, any clues on how i can set up the redirection?

Link to comment
https://forums.phpfreaks.com/topic/184950-redirect-after-sucsessful-login/
Share on other sites

one common method is to set a cookie or a session value with the page that they were on. for example when the user visits protectedpage.php and doesnt have rights you would set a cookie with that pages location. then when the user logged in on login.php you would check if that cookie was set and if so you would redirect them to the url that is in the cookie and if not you would redirect them to there normal page. same idea for sessions but typically session arent set until a user is logged in thats why i went with the cookie example.

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.