protected function updateTrackedInfo($session, $sessionKey, $trackInfoArray, $limit = 5)
{
// save the url, controller and action in the session
$value = json_decode($session->get($sessionKey), true);
if (is_null($value)) {
$value = array();
}
// add new value as first value (to the top of the stack)
array_unshift($value, $trackInfoArray);
// remove last value, if array has more than limit items
if ($limit > 0 and count($value) > $limit) {
array_pop($value);
}
// set the session value
$session->set($sessionKey, json_encode($value));
}