Sampathkumar
Sampathkumar

Reputation: 121

Yii passing value from one controller to another

I am using Yii framework for my application. My application contain 4 controllers in which I want to pass value from one controller to another.

Let us consider site and admin controller. In site controller, I manage the login validation and retrieves admin id from database. But I want to send admin id to admin controller.

I try session variable, its scope only within that controller.

Please suggest the possible solution for me.

Thanks in advance

Upvotes: 1

Views: 1308

Answers (1)

darkheir
darkheir

Reputation: 8950

You want to use a redirect:

In the siteController file

public function actionLogin()
{
    //Perform your operation
    //The next line will redirect the user to 
    //the AdminController in the action called loggedAction
    $this->redirect(array('admin/logged', array(
        'id' => $admin->id,
        'param2' => $value2
    )));
}

in the adminController file

public function loggedAction($id, $param2)
{
    //you are in the other action and params are set
}

Upvotes: 2

Related Questions