php - Yii2 login. Yii::$app->user->login($user, 0) doesnt save -


I am trying to apply the login to my site. But Yii :: $ app- & gt; User- & gt; Login ($ user, 0) does not save the identity.

When I log in now it works fine:

  if (Yii :: $ app-> user- & gt; login ($ user, 0 )) {Var_dump (Yii :: $ app-> User-> Identity); } Else {echo 'did not login'; }  

show var_dump () identity

but when I show another controller var_dump () < Code> NULL :

  // Another controller trying to get recognition in var_dump (Yii: $ app-> User-> Identity);  

Does anybody know about this problem?

OK. The Russian yii Forum answered in the boy. ()

  Namespace ap model; Use Yii \ db \ ActiveRecord; Use Yii \ web \ IdentityInterface; Class User ActiveRecord implies the IdentityInterface {}  

I should implement the IdentityInterface and I forgot it now works well!


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -