Let do some detective work, I think you footer file is called counter.php which contains session_start on line 2. You have included this file into the footer of index.php which also has its own session_start. This could be one of the reason.
If not, check this out:
warning-session-start-function-session-start-cannot-send-session-cache-lim[
^]
++++++++++++++++++++++++++++++++++++++++++++
This is added in response to your further queries:
1. The php code shown by you is using a text file "counter.txt" to store the visitor number, the "$_SESSION['hasVisited']" is redundant here, it is not needed, the following code will do, assuming you save it as "counter.php" in a folder called "includes":
<?php
$counter_name = "counter.txt";
if (!file_exists($counter_name))
{
$f = fopen($counter_name, "w");
fwrite($f,"0"); fclose($f);
}
$f = fopen($counter_name,"r");
$counterVal = fread($f, filesize($counter_name));
fclose($f);
$counterVal++;
$f = fopen($counter_name, "w");
fwrite($f, $counterVal);
fclose($f);
echo "visitor number $counterVal";
?>
Your next query on how to include this "counter.php" into another php file, say "index.php" which is located along side the "includes" folder, adapt this:
";
echo "This is the main content<br>";
echo "This is the footer content<br>";
include "./includes/counter.php";
?>
Now when you launch the"index.php", the visitor number will increase at every refresh. A text file called "counter.txt" would have been created in along side the "index.php".