如何在控制器中保存id?

I have a action which i am calling it two time

Controller.php
UserController extends Controller {
    public actionCopy($id = false){

    if($id){
    //redireting to a view
    }
    else{
    //rediredtion to a differnet view
    }


    }
}

I am getting a id first then from first view i am again coming to Copy action with no id so else part is running nw but in this i want to get the $id which i get from first request.

I have tried to define a global variable in controller like

Controller.php
    UserController extends Controller {
public $user;
        public actionCopy($id= false){

        if($id){
    $this->user = $id;
        //redireting to a view
        }
        else{
        echo $this->user ;// but it has nothing
        //rediredtion to a differnet view
        }


        }

    }

and set it like this.

I know that if condition is not executing so $id has no value but i set $this->user first time then why it has no value.

Any help is appreaciated

Just try this,

class UserController extends Controller {
    public actionCopy($id = false){     
        if($id){
            //set up a session here
            Yii::app()->session['_data_id'] = $id;

            //remaining code here               
        }
        else{
            $id=isset(Yii::app()->session['_data_id'])?Yii::app()->session['_data_id']:NULL; // the id you want from previous request
            if($id!=NULL){
                //remaining code
                unset(Yii::app()->session['_data_id']); //clear it after use
            }
        }
    }
}