Simple question from a Yii Beginner

I am new to php and Yii but have experience with OOP. I went through the process of setting up the same application as shown in the screencasts. While looking through how the M, V and C interact with each other I came upon this code in the SiteController.php of the demo application and had a question about it:

/**


 * Displays the login page


 */


public function actionLogin()


{


	$model=new LoginForm;





	// if it is ajax validation request


	if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')


	{


		echo CActiveForm::validate($model);


		Yii::app()->end();


	}

[b]

	// collect user input data


	if(isset($_POST['LoginForm']))


	{


		$model->attributes=$_POST['LoginForm'];


		// validate user input and redirect to the previous page if valid


		if($model->validate() && $model->login())


			[u]$this->redirect(Yii::app()->user->returnUrl);[/u]


	}[/b]


	// display the login form


	$this->render('login',array('model'=>$model));


}

I have two questions:

  1. What is this code which is in bold doing? Is it trying to find out whether the user is already logged in, and if he/she is, then redirecting it to the URL he/she was earlier at?

  2. When i looked up the function definition for redirect method on the CController, it has an optional parameter $terminate which is set to true by default. Does that mean that once the user is redirected to the URL, the application will terminate? That does not make sense to me.

Hope you can help. Thanks.

  1. It takes info from the login form and tries to actually log user in. If it went fine then redirect is performed.

  2. Yes, it means exactly that. PHP is stateless in its nature when used in a "usual" way so it creates new application instance on each request.

Thanks. This helps.

Visit First These links gives best idea to understand MVC in Yii Framework and then Goes for other http://www.yiiframework.com/doc/guide/1.1/en/basics.mvc