How to retain dropdownList value after page reload

Hello

How can I keep dropdownlist value when page reloaded?




<?php 

$parentc= Category::find()->where(['parent_id'=>'y'])->All();

$a = ArrayHelper::map($parentc,'id','name');

ActiveForm::begin(['action'=>['search/index']]);

echo  $form->field($searchModel, 'cat')->dropDownList($a, ['prompt'=>'Select...']);

ActiveForm::end();

?>






$a = ['a' => 'Item A', 'b' => 'Item B', 'c' => 'Item C'];

$form->field($searchModel, 'cat')->dropDownList($a, ['prompt'=>'Select...']);



Thank You, But I want dropdown list still showing selected value after page reloaded.

Use a cookie or use a GET parameter - or take this and modify it: https://github.com/lajax/yii2-language-picker