Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

roblesterjr04's avatar

I can't seem to get manual authentication to work, or the session to keep.

I'm trying to manually log in a user using Auth::login($user, true)

Here is the code in the controller:

$user = User::where('email', $request->email)->first();
Auth::login($user, true);
return redirect()->to('/dashboard');

When I redirect, i get bounced back to the login screen.

Here is my routes file:

Route::group(['middleware' => ['web']], function() {
    Auth::routes();
    Route::get('/', function () {
        return view('welcome');
    });
    Route::get('/dashboard', 'admin\adminRootController@dashboard')->middleware('auth');
});

I have tried every other solution I have found, and i still can't get it to work. someone please humor me and help me work this out. Please don't ignore it because "its been asked." I've already looked at 20 different posts related to this, and none of the solutions worked.

0 likes
2 replies
roblesterjr04's avatar

I was trying to bypass the password.

The problem is actually because I was running my auth::login from an endpoint within the api::routes, and the sessions isn't persistent there.

Problem is solved.

Please or to participate in this conversation.