Laravel Auth:Attempt() Will Not Persist Login

Laravel 7 authentication not persisting

Typical ID10T error on my part. I didn't realize that I had implemented Illuminate\Contracts\Auth\Authenticatable manually on my model before extending the Illuminate\Foundation\Auth\User class. PHPStorm had stubbed out those methods for me...

Removing those stubbed methods worked.

laravel auth and session not persisting

Your query seems to be incomplete, from what i understand you are able to get the index page after passing the authentication check only once, and that is by using this method:

public function postLogin() {
$data = array();
$secured = ['user_email' => $_POST['email'], 'password' => $_POST['password']];
if (Auth::attempt($secured, isset($_POST['remember']))) {
if (Auth::user()->user_status == 1 ) {
return Return View::make(user.index);
}
else {
$data['success'] = false;
}
}
else {
$data['success'] = false;
}
return $data;
}

try using a different browser to make sure there is no cookie storage restrictions in the client side and check the app/config/session.php file and see if you have configured the HTTPS Only Cookies according to your needs.

and just on an additional note this line "return Return View::make(user.index);" looks vague.

Laravel 8 - Auth::login() do not save $user data on session

I wanted to do an authentication without any type of database query.

The way I was doing it would not work, because at some point there was still an attempt to go to the database to get the user with that specific identifier.

So, I set out to implement my own Guard, which solved my problem.

For that, I followed this example: Laravel: How to authenticate users without DB, but I adapted to my need



Related Topics



Leave a reply



Submit