I've spent the last 8 hours trying to crack this one.
I'm logging the URL's which users view in $_SESSION array (on wordpress)
from my history.php which I'm including on all pages:
session_start();
$currentpageurl= esc_url($_SERVER['REQUEST_URI']);
is_array($_SESSION["pageurl"]) or $_SESSION["pageurl"] = array();
$_SESSION['pageurl'][] = $currentpageurl;
Then I'm calling the array items to see the log like so:
foreach($_SESSION['pageurl'] as $key=>$value)
{
echo 'Page view '.$key.' was '."'".$value."'".' <br />';
}
That all works. But in the results, the post before the one I visit logs as a 'visited page' as well. I checked all of my files for broken links that may cause http requests, and everything checks out. I even changed Request URI
to other things from $_SERVER
like SCRIPT URI
and still the post before always loads.
If I visit these pages:
mysite.com/article-y
mysite.com/article-z
The array shows the page before (which was not visited):
mysite.com/article-y
mysite.com/article-x <--not visited, but somehow in session array
mysite.com/article-z