Hello. Help me please. There is a controller that Ajax-som takes values. Task: after writing a user name to the check?

if(Yii::app()->request->isAjaxRequest){ Yii::app()->user->name = 'reg'; } 

This code does not give a result:

 class ChekSingupController extends Controller { public function actionIndex() { // если запрос асинхронный, то нам нужно отдать только данные if(Yii::app()->request->isAjaxRequest){ if(Yii::app()->request->isAjaxRequest){ Yii::app()->user->name = 'reg'; } // Завершаем приложение Yii::app()->end(); } } 
  • @Maksim147, If you are given a comprehensive answer, mark it as correct (click on the check mark next to the selected answer). - Deleted

1 answer 1

after checking the username in the check?

???

Yii :: app () -> user-> name = 'reg';

In an amicable way, this should keep everything in a persistent state, but you can try using setState:

 Yii::app()->user->setState('name', 'reg'); 

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

Calling this is optional (and not worth it).

  • Thank. Works - Maxim147