You're dealing with an array, not with an object, so you should use
$_SESSION['stats']['likecount']++;
Pregunta
I have created a session variable to store some basic stats:
$_SESSION['stats'] = array('likecount' => 0, 'failedlikes' => 0);
Further down I have a line which increments it:
$_SESSION['stats']->likecount++;
However, this throws the error Attempt to increment/decrement property of non-object
. What am I doing wrong?
Solución
You're dealing with an array, not with an object, so you should use
$_SESSION['stats']['likecount']++;