Solarpitch Posted June 22, 2007 Share Posted June 22, 2007 Hi Guys, I have the following code that sets a session to return the user back to the previous page they were on. $_SESSION['last_page'] = (!isset($_SESSION['curr_page'])) ? "http://www.mydomain.com/page1.php" : $_SESSION['curr_page']; $_SESSION['curr_page'] = $_SERVER['PHP_SELF']; Bascially I am looking for a better way to do this. The problem with this is you need to hard code what the previous page was. Is there anyway to dynamically set what page the user was on. What if the last page URL had an id in it like... http://www.mydomain.com/?id=14 How could I set this as the previous page in a session? Quote Link to comment https://forums.phpfreaks.com/topic/56774-setting-a-session-to-store-users-last-page-visited/ Share on other sites More sharing options...
king arthur Posted June 22, 2007 Share Posted June 22, 2007 If you have this on every page, then your curr_page variable will always be set. So copying it to last_page before setting it, will always give you the previous page except when the visitor first lands on your site. Quote Link to comment https://forums.phpfreaks.com/topic/56774-setting-a-session-to-store-users-last-page-visited/#findComment-280421 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.