存储统计信息PHP代码 - 用于循环

I have constructed a dice game that asks the user how many times he wants to roll the dice. I have a for loop to and rollercount for each number of the dice. Problem is that I want ALL of the rolls to be counted in the stats.

For example: Users puts in 6 times, and then 3 times, I want all the 9 rolls to be displayed. Now my for loop resets when the users enters a new number. I understand that the variable "rollercount" is resetted to 0 every time, but how do I avoid this? Hope the question is clear.

$rollercount = 0;

for ($i = 1; $i <= $dice; $i++){
    $roll = rand(1,6);
    if($roll == 1) {
        $rollercount1++;
        echo "Du rullade en etta" . $rollercount1. " times";
    }
}

There is a big issue here. When a page is rendered and sent to the browser, ALL DATAS are lost. When a new request is provided, with the new dice requested, you cannot know if it is the first time the page is displayed or other dices where calculated The only way to solve this, is using cookies or session variables or other save method of this type I suggest you to study PHP session