I have the following that stores the previous 10 URL\'s into a session:
function curPageURL() {
$pageURL = \'http\';
if ($_SERVER[\"HTTPS\"] == \"on\") {$pageU
if(!in_array($CurrentPage, $_SESSION['pages']) {
$_SESSION['pages'][] = $CurrentPage;
}
Could array_unique be of help?
instead of $_SESSION['pages'][] = $CurrentPage
try $_SESSION['pages'][$CurrentPage] = 1
/edit: to keep items sorted, unset first:
unset($_SESSION['pages'][$CurrentPage]);
$_SESSION['pages'][$CurrentPage] = 1;
Just after
$_SESSION['pages'][] = $CurrentPage;
you need to add
$_SESSION['pages'] = array_unique($_SESSION['pages']);
Docs are available here
This method requires less processing, as it's a native function. Performing an 'if' on each item in the array could potentially be quite costly.