How can I increment a value by 10 after each page request? e.g

I go on index.php and see an output of 10.
when I refresh, it increments by 10 and changes to 20 and so on…

Would this increment be on a per-user basis rather than globally? If so, you can use: -


function increment_session_counter($value = 10, $key = 'counter'){
    if( ! array_key_exists($key, $_SESSION)){
        $_SESSION[$key] = 0;
    return $_SESSION[$key] += $value;

increment_session_counter(); //by default (10)
increment_session_counter(5); //by 5

Hello the increment is working however for some reason it starts from 400. How can I specify which number to start from

^ problem solved, has to destroy sessions.

Also, how can I reset the counter when the user leaves the page, without destroying the entire session?