southasia Posted January 20, 2010 Share Posted January 20, 2010 How to use cookie and session in following manner? Let say we login to the phpfreaks and left it open about thirty minutes, the next time we click on any menu link if the cookie is expire it will redirect to the login page for authentication again. After login it will redirect back to the page that user left the last time. How can I achieve that? Link to comment https://forums.phpfreaks.com/topic/189114-remember-user-login-url/ Share on other sites More sharing options...
JAY6390 Posted January 20, 2010 Share Posted January 20, 2010 check the referrer on the login page, using $_SERVER['HTTP_REFERER'] Link to comment https://forums.phpfreaks.com/topic/189114-remember-user-login-url/#findComment-998417 Share on other sites More sharing options...
southasia Posted January 20, 2010 Author Share Posted January 20, 2010 It doesnt help. Link to comment https://forums.phpfreaks.com/topic/189114-remember-user-login-url/#findComment-998503 Share on other sites More sharing options...
pneudralics Posted January 20, 2010 Share Posted January 20, 2010 I have an "idea"...what if you record the url of the last page the user was on? Once the cookie dies and the user is required to login just redirect it to the last page from the database.. Link to comment https://forums.phpfreaks.com/topic/189114-remember-user-login-url/#findComment-998504 Share on other sites More sharing options...
southasia Posted January 20, 2010 Author Share Posted January 20, 2010 Yeah thats what I want and working on it. But still can not figure it out how yet. Let say i have 1. Login/Index Page 2.Main Page 3.Sub Page Link to comment https://forums.phpfreaks.com/topic/189114-remember-user-login-url/#findComment-998515 Share on other sites More sharing options...
pneudralics Posted January 20, 2010 Share Posted January 20, 2010 Here's what I would do... I'm sure there are way better ways to do it but I think it'll get the job done. 1. Create a field in the database and name it something like lastlink 2. Include a file on every page. All that file does is update the current url to the user's lastlink field. Everytime a user clicks to go somewhere on the website it'll reactivate that file and therefore it'll update the lastlink field. 3. Once cookie dies and user logs in, just make it redirect to the url in lastlink. That's just the gist of it. I'm sure you want to add more things to it. Link to comment https://forums.phpfreaks.com/topic/189114-remember-user-login-url/#findComment-998524 Share on other sites More sharing options...
southasia Posted January 20, 2010 Author Share Posted January 20, 2010 Thanks, that is one interesting solution i believe. I will still like to work around with cookie and session though. Link to comment https://forums.phpfreaks.com/topic/189114-remember-user-login-url/#findComment-998606 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.