Home > database >  How to fix strange behavior of Auth::loginUsingId() when I set remember me argument to true in larav
How to fix strange behavior of Auth::loginUsingId() when I set remember me argument to true in larav

Time:01-03

in AuthController, in order to login the user by id, I tried Auth::loginUsingId($id, $remember) with both true and false values for $remember. in both cases, login is successful, but the problem is when I set $remember = true, it will redirect back and the codes after that will be ignored:

set to false

Auth::loginUsingId($id, false);
dd('test'); // this line or anything else will execute after logging the user in

set to true

Auth::loginUsingId($id, true);
dd('test'); // this line or anything else will ignored and redirect back immediately
// after loggin the user in

I totally confused why this happens. I appreciate any help.

CodePudding user response:

if you are sure that the login system works fine and the only problem is with remember me option, it could be because of missing remember_me column or some changes that you've made on remember_me column that you shouldn't do in your users migration.

make sure you have the following line in your users migration, if you are using version 8 of laravel as you have used it's tag:

$table->rememberToken();

and if you are using older version of laravel, you should have the following line:

$table->string('remember_me', 100)->nullable();
  • Related