Hallo,
Hier die fertige Lösung:
<?php
$counterFileName = "counter.txt";$counterstand = (int) file_get_contents($counterFileName);
if ($_SESSION['count'] != 'count') {
$counterstand++;session_start();
$_SESSION['count']='count';} else {
fclose ($counterstand);
}
?>
<br><p class="artikel">Besucher:<br><?=$counterstand?></p></body></html>
Wenn du es mit Session statt mit Cookie machen willst, dann wohl eher so:
~~~php
<?php
session_start();
error_reporting(E_NOTICE|E_ALL);
$counterFileName = "counter.txt";
$counterValue = (int) file_get_contents($counterFileName);
if (!isset($_SESSION['counted'])) {
$_SESSION['counted']="counted";
$counterValue++;
file_put_contents($counterFileName, $counterValue);
}
?>
<p class="artikel">Besucher: <?=$counterValue?></p>
Gruß
jobo