Skip to content
Itstuffsolutions

Itstuffsolutions

  • Home
  • post
  • About Us
  • Contact Us
Laravel 12 Custom Login with Remember Me Feature

Laravel 12 Custom Login with Remember Me Feature

June 12, 2025 Itstuffsolutions

We often see the “Remember Me” option on login pages — it allows users to stay logged in even after they close the browser, improving user experience and convenience.

If you’re using Laravel’s default authentication scaffolding (like Breeze, Jetstream, or UI), then good news — Laravel already includes “Remember Me” functionality by default. You just need to make sure the remember checkbox is included in your login form.

However, when building custom login and registration logic, many developers struggle to get the “Remember Me” feature working correctly. Often, users are still logged out after closing the browser, even though they checked the box.

This usually happens due to missing setup steps, like forgetting to include the remember_token column in the database or not passing the remember flag during login  and Laravel handles the rest behind the scenes.

🧠 Want to Build Custom Login from Scratch?

If you’re starting from scratch or want a full guide to create your own custom login and registration system in Laravel 12, I recommend checking out this detailed article: Complete Laravel 12 Custom Login and Registration Tutorial for Beginners It covers login, register, validation and more — great for beginners or anyone customizing beyond the default setup.

In this tutorial Laravel 12 Custom Login with Remember Me Feature, I’ll show you how to add “Remember Me” functionality in custom login.

Step 1: Ensure remember_token Column Exists

First, check that users table has a remember_token column, as it is required to store the token used for “remember me” sessions in Laravel.

If it’s missing, add it via a migration:

Schema::table('users', function (Blueprint $table) {
    $table->rememberToken();
});

Then run:

php artisan migrate

Step 3: Check your login form. If the “Remember Me” checkbox is not present, add the following code:

 <div class="form-check">
    <input class="form-check-input" type="checkbox" name="rememberMe" id="rememberMe">
    <label class="form-check-label" for="rememberMe">Keep me logged in</label>
</div>

Step 4: Custom Login Method with remember Support

Now, add the following code to your login method in your LoginController:

public function doLogin(Request $request): RedirectResponse
    {
        $request->validate([
            'email' => 'required',
            'password' => 'required',
        ]);
        $remember   = $request->has('rememberMe');//true if checked remember me
        $credentials = $request->only('email', 'password');

        //Auth::attempt($credentials, $remember)
        if (Auth::attempt($credentials, $remember)) {
            return redirect()->intended('dashboard')
                        ->withSuccess('You have Successfully loggedin!!');
        }
   
        return redirect("login")->withError('Oppes! Invalid credentials');
    }
Laravel 12 Custom Login with Remember Me Feature
Login with remember preview

Hope it helps.

Related

Categories Laravel, Laravel 12 Tags laravel, login
Laravel 12 Authentication with Breeze Tutorial
How to Send SMS to Mobile Number in Laravel 12 Using Twilio API

Recent Posts

  • How to Increase or Decrease Laravel Session Lifetime
  • Laravel 12 How to Send WhatsApp message using Twilio
  • How to Send SMS to Mobile Number in Laravel 12 Using Twilio API
  • Laravel 12 Custom Login with Remember Me Feature
  • Laravel 12 Authentication with Breeze Tutorial

Categories

  • Laravel
  • Laravel 12
Logo
  • About Us
  • Contact Us

© 2025 All Rights Reserved

  • Disclaimer
  • Privacy Policy