Is it possible to redirect a page to two pages previous on the users navigation.
I found this
$_SERVER['HTTP_REFERER'];
But it only goes back one, and I need two.
Is it possible to redirect a page to two pages previous on the users navigation.
I found this
$_SERVER['HTTP_REFERER'];
But it only goes back one, and I need two.
Start a session, and track the user's navigation up to n-levels deep (where 'n' is whatever you'd like it to be).
Relying on the Referer header is highly discouraged since it's a) an optional header that some gateways/proxies strip off anyway, and b) easily altered/faked by the user.
I actually do have a session going by how to I trap how many levels they have been through?
Well it would depend on your needs. You could just do something like:
define('MAX_PAGES_STORED', 2);
if(empty($_SESSION['nav']))
$_SESSION['nav'] = array();
// and now to actually handle the storage of the navigation data...
array_unshift($_SESSION['nav'], 'info about current page here... e.g. filename or something');
if(count($_SESSION['nav']) >= MAX_PAGES_STORED)
$_SESSION['nav'] = array_slice($_SESSION['nav'], 0, MAX_PAGES_STORED);
Doing that would make $SESSION['nav'][0] be the current page, $SESSION['nav'][1] be 1 page ago, $_SESSION['nav'][$x] be $x pages ago, etc. etc. up until you reach the MAX_PAGES_STORED constant.