php - yii2 login user manually with getting user and password from ajax

870

i send mobile number as username and active_code as password from view file(ajax) to action with jqueryand i want login user with this data.

This code is my action:

//if entered information is correct then do:
$identity = \common\models\User::findOne(["username"=>$mobile]);
if(Yii::$app->user->login($identity))
   return 100;
else
   return 500;

It is worked(return 100) but after page refreshed, it seems user not logged in! Is there any way to do this?

People are also looking for solutions to the problem: javascript - Can not get data from AJAX request to the Coinhive API

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.