[Solved] Controller action runs 2 times in one load

i have simple function in my controller




public function actionTest()

{

    $counter = Yii::app()->session->get('counter');

    if ($counter == null) {

        $counter = 0;

    }

    Yii::app()->session->add('counter', $counter+1);

    echo Yii::app()->session->get('counter');

}



after refresh i am getting 2 times bigger counter then it have to be. This is bug or that have to be?

how to make run only one time controller action?

Hi,

In my experience, the most suspicious are the browsers. For some reason they tend to make the identical 2nd request when they failed to get some files in the 1st request. The notorious one among such files is "favicon.ico". Also you should check your css and js files that are missing.

thanks for explanation yes, that was true with chrome browser i got 2 requests not 1, with firefox browser i got 1 request.