I am trying to track the pages a user visits and the day of the visits using session variables. In my pages, I assigned the variables as arrays like this:
session_start();
$_SESSION['page']=array();
$_SESSION['page'][]=$_SERVER['REQUEST_URI'];
$_SESSION['time']=array();
$_SESSION['time'][]=date("m/d/y", time());
I used the following script to print the variables out:
<?php
session_start();
print_r($_SESSION['page']);
print_r($_SESSION['time']);
?>
After I visited several pages, the above script only printed the last page I visited instead of showing all the pages. Can anyone help me troubleshoot please? Thank you.
$_SESSION['page']=array();Every time you load a page, you are replacing'page'with a blank array.