set_select()在codeigniter框架中不起作用

I want the select box show the same value before the from submit after the redirection in this code $cat value come to the session i am not using validation rule for select box i want only the select box not change after the redirection Select Leave Category... leave_category_id ?>"

                <?php echo set_select('leave_category_id', $cat, true); ?>> <?php echo $v_category->category ?>  </option>

    <?php endforeach;
    ?>
</select>

Try

<select name="leave_category_id" class="form-control" onchange="check_leave_category(this.value)" required  >
    <option>Select Leave Category...</option>
    <?php foreach ($all_leave_category as $v_category) :

        // Using short tag
        //$v_category->leave_category_id == $cat ? $selected = 'selected' : $selected = '';

        // without using short tag
        if($v_category->leave_category_id == $cat) $selected = 'selected'; else $selected = '';
        ?>
        <option value="<?php echo $v_category->leave_category_id ?>" <?php echo $selected?> > <?php echo $v_category->category ?>  </option>

    <?php endforeach;
    ?>
</select>

There are two things to keep in mind: First you have to use the validation class to be able to use the set_select() function. Second you have to pass the database information to that function, like this:

<select name="myselect">
  <option value="one" <?php echo set_select('myselect', 'one', ($model->selection == 'one')); ?> >One</option>
  <option value="two" <?php echo set_select('myselect', 'two', ($model->selection == 'two')); ?> >Two</option>
  <option value="three" <?php echo set_select('myselect', 'three', ($model->selection == 'three')); ?> >Three</option>
</select>

If $model->selection is two, then the second option will be selected in the example above.

see the link