soycharliente Posted May 11, 2007 Share Posted May 11, 2007 Hey guys. I don't really know the terminology to describe what I want to do, so I apologize if the subject is too vague. When you try to go to a page that you need to be logged in to see, it first takes you to a login page. Once you successfully log in, it takes you to that original page that you tried to access instead of the default home page. I've been doing PHP for a little while (oh about... 6 or 8 months) so I don't think I need any code, just some structure/pointers because I can't really think it through. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/50925-solved-keeping-track-of-page-while-logging-in/ Share on other sites More sharing options...
Trium918 Posted May 11, 2007 Share Posted May 11, 2007 1. Start session 2. Register the Session 3. End the Session Quote Link to comment https://forums.phpfreaks.com/topic/50925-solved-keeping-track-of-page-while-logging-in/#findComment-250478 Share on other sites More sharing options...
soycharliente Posted May 11, 2007 Author Share Posted May 11, 2007 So just store it in a session var? And if that var is set, put that var in the action of the login form, and if not, use some default page? Quote Link to comment https://forums.phpfreaks.com/topic/50925-solved-keeping-track-of-page-while-logging-in/#findComment-250480 Share on other sites More sharing options...
Daniel0 Posted May 11, 2007 Share Posted May 11, 2007 Check if there is a valid session. If yes: Display page - If no: Display login page or redirect to it. Quote Link to comment https://forums.phpfreaks.com/topic/50925-solved-keeping-track-of-page-while-logging-in/#findComment-250481 Share on other sites More sharing options...
soycharliente Posted May 11, 2007 Author Share Posted May 11, 2007 No, no no. If they aren't logged in, I already have it redirecting to the login page. I want to be able to take them to page they tried to access first instead of the default page you go to once logged in. Quote Link to comment https://forums.phpfreaks.com/topic/50925-solved-keeping-track-of-page-while-logging-in/#findComment-250482 Share on other sites More sharing options...
soycharliente Posted May 11, 2007 Author Share Posted May 11, 2007 .bump. Quote Link to comment https://forums.phpfreaks.com/topic/50925-solved-keeping-track-of-page-while-logging-in/#findComment-250517 Share on other sites More sharing options...
Psycho Posted May 11, 2007 Share Posted May 11, 2007 There are different ways to handle it, but here is a basic methodology. 1.User attempts to access a restricted page (Page A) 2. Page A checks to see if user is logged in (usually with an include file) 3. If user is not logged in, the current URL for Page A is saved to an "original page" session variable and the user is redirected to a login page 4. After the user successfully logs in the login page checkes if the "original page" session variable is set. If so the user is redirected to that page - if not the user is redirected to a default page. Quote Link to comment https://forums.phpfreaks.com/topic/50925-solved-keeping-track-of-page-while-logging-in/#findComment-250520 Share on other sites More sharing options...
Trium918 Posted May 11, 2007 Share Posted May 11, 2007 So just store it in a session var? And if that var is set, put that var in the action of the login form, and if not, use some default page? If you understand what you just said, then try it your way. Here are three files that will assist you! [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/50925-solved-keeping-track-of-page-while-logging-in/#findComment-250561 Share on other sites More sharing options...
Daniel0 Posted May 11, 2007 Share Posted May 11, 2007 Just send them to whatever $_SERVER['HTTP_REFERER'] holds. Quote Link to comment https://forums.phpfreaks.com/topic/50925-solved-keeping-track-of-page-while-logging-in/#findComment-250578 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.