This issue has been haunting me for a long time, and I haven't been able to solve it.
The following code is part of a basic assignment: the page should record every user access in the form of cookies. I opted for a main cookie that records the number of accesses and several "acc-N" cookies (with timestamp) for each individual access.
<?php
if(!isset($_COOKIE["numAcc"]))
$num = 1;
else
$num = (int)$_COOKIE["numAcc"] + 1;
setcookie("numAcc", $num, time() + (86400 * 365), "/");
setcookie("acc-".$num, date("Y-m-d_H.i.s"), time() + (86400 * 365), "/");
?>
Using XAMPP with PHP 7.3.9, the first "setcookie" causes the following error:
"Parse error: syntax error, unexpected '' (T_STRING), expecting ')' in assignment.php on line 7
I have no clue as to what is causing it, the second "setcookie" works fine when the first is commented out.