Autoincrement numeric variable in PHP on Refresh

前端 未结 4 1608
一生所求
一生所求 2021-01-24 08:56

How do I use PHP to auto-increment a numeric variable on page refresh?

Foe example, for $i=10 there is an output of this:

Page has be

4条回答
  •  逝去的感伤
    2021-01-24 09:21

    You can easily do it with the help of cookies

    $cookieName = 'count';
    $count = isset($_COOKIE[$cookieName]) ? $_COOKIE[$cookieName] : '';

    $newCount = $count+1;
    setcookie($cookieName,$newCount);

    $count will return back the updated value

提交回复
热议问题