How do I get list of all pages visited during the session ex

How do I get list of all pages visited during the session, example below

-You may use the Superglobal variable $_SERVER[“PHP_SELF”] to access the name of the current page.

-To declare an empty array use syntax: $some_array = [];

-To append to this array: $some_array[] = ‘Appended string’;

-you may use foreach() to retrieve the content of the session array

CAN SOME ONE HELP ME WITH THE CODE TO GET THE DISPLAY ABOVE!

Do not send me this code IT DOESN\'T WORK:

session_start();

echo \'Page1.php\';
echo \'Page2.php\';
echo \'Page3.php\';
echo \'Page4.php\';
echo \'Page5.php\';
$i=0;
if(isset($_GET[\'p1\']))
{
$file_array[$i]=\"page1.php\";
$i++;
}
if(isset($_GET[\'p2\']))
{
$file_array[$i]=\"page2.php\";
$i++;
}
if(isset($_GET[\'p3\']))
{
$file_array[$i]=\"page3.php\";

$i++;

}

if(isset($_GET[\'p4\']))

{

$file_array[$i]=\"page4.php\";

$i++;

}

if(isset($_GET[\'p5\']))

{

$file_array[$i]=\"page5.php\";

$i++;

}

echo \"The pages you visited are :\";
for($i=0;$i<=$file_array[$i];$i++)
}
?>

This is what I came up with so far CAN SOMEONE MODIFY THIS WHERE I AM GETTING THE VISITED PAGES WITH NO ERRORS.

session_start();
//      .$_SESSION[\'sess_var\'].\'
\';
$array_var = [];
$array_var[]= \'tom\';
$array_var[]=\'alice\';
$array_var[7] = \'Smith\';

echo $_SERVER[\'PHP_SELF\'];

$_SESSION[\'name\'] = \'Tom Smith
\';
// echo $_SESSION[\'name\'];
$currentpageurl = $_GET[\'name\'];
$_SESSION[\'name\']= array();
$_SESSION[\'name\'][] = $currentpageurl;
$_SESSION[\"name\"] = array_slice($_SESSION[\"name\"], -10);
?>


Page 1
Page 2
Page 3
Page 4
Page 5

131.183.222.38 etest/Ch x C 131.183.222.38 examples/page3.php The last page you visited was etest/Chapter23/lab examples pages.php List of pages visited: /~etest/Chapter23/lab examples pagel.php etest Chapter23/lab examples/page2.php /~etest/Chapter23/lab examples/page3.php etest Chapter23/lab examples page2.php etest Chapter 23/lab examples pag /~etest Chapter23 lab examples page3.php /~etest/Chapter23/lab examples/page4.php /~etest/Chapter23/lab examples/page5.php /~etest Chapter23/lab examples page3.php Page 1 Page 2 Page 3 Page 4 Page 5

Solution

session_start(); if(!empty($_SESSION[\'visited_pages\'])) { $_SESSION[\'visited_pages\'][\'prev\'] = $_SESSION[\'visited_pages\'][\'current\']; }else { $_SESSION[\'visited_pages\'][\'prev\'] = \'No previous page\'; } $_SESSION[\'visited_pages\'][\'current\'] = $_SERVER[\'REQUEST_URI\'];
How do I get list of all pages visited during the session, example below -You may use the Superglobal variable $_SERVER[“PHP_SELF”] to access the name of the cu
How do I get list of all pages visited during the session, example below -You may use the Superglobal variable $_SERVER[“PHP_SELF”] to access the name of the cu

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site