Here is a piece of code that is on the top of every page of my website.
When going from one page to another, the last page should be echoed to the screen. Instead $_SESSION['lastPage'] is remaining "http://www.mysite.com".Code:<?php if(strlen($_SESSION['currPage']) > 0){ $_SESSION['lastPage'] = $_SESSION['currPage']; } else { $_SESSION['lastPage'] = "http://www.mysite.com"; } $_SESSION['currPage'] = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; echo $_SESSION['lastPage']; ?>
I thought it may have been the lack of session_start(); (which I removed because of header conflicts), but when I added it, I still recieved the same result.
I know $_SESSION['currPage'] is being set, as I commented out the 4th last line to test it.
What could possibly be the problem? Or is there something wrong with the logic?
At the end, this code will be used to utlize a 'Back' button. (Instead of history.go(-1); in javascript)




Reply With Quote