phpfan101 Posted December 13, 2009 Share Posted December 13, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/184950-redirect-after-sucsessful-login/ Share on other sites More sharing options...
ngreenwood6 Posted December 13, 2009 Share Posted December 13, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/184950-redirect-after-sucsessful-login/#findComment-976359 Share on other sites More sharing options...
phpfan101 Posted December 13, 2009 Author Share Posted December 13, 2009 hmmm, yea, cookies is what i was thinking, but i have never used them yet Guess it wont hurt Quote Link to comment https://forums.phpfreaks.com/topic/184950-redirect-after-sucsessful-login/#findComment-976361 Share on other sites More sharing options...
ngreenwood6 Posted December 13, 2009 Share Posted December 13, 2009 yeah it wont hurt to learn there are alot of good examples out there. Quote Link to comment https://forums.phpfreaks.com/topic/184950-redirect-after-sucsessful-login/#findComment-976364 Share on other sites More sharing options...
teamatomic Posted December 13, 2009 Share Posted December 13, 2009 I use $_SESSION['breadcrumb'] = "$_SERVER['SCRIPT_FILENAME']"; Quote Link to comment https://forums.phpfreaks.com/topic/184950-redirect-after-sucsessful-login/#findComment-976381 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.