Skip to content

Itstuffsolutions

Step-by-Step Guide

  • Home
  • Our Latest Posts
  • 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.

Table of Contents

  • 🧠 Want to Build Custom Login from Scratch?
  • Step 1: Ensure remember_token Column Exists
  • Step 2: Check your login form. If the “Remember Me” checkbox is not present, add the following code:
  • Step 3: Custom Login Method with remember Support

🧠 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 2: 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 3: 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.

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

  • Laravel 12 Create Custom Error Page Example
  • Laravel 12 CORS Middleware Configuration Example
  • Laravel 12 RouteServiceProvider Configuration Tutorial
  • Laravel 12 Restrict/Block User Access from IP Address
  • How to Install Bootstrap 5 in Laravel 12 with Vite

Categories

  • Ajax Autocomplete search
  • Array Validation
  • Auth
  • Block IP
  • Bootstrap-Vite
  • Change Date Format
  • Client IP
  • collection
  • CORS Middleware
  • Custom Error Page
  • custom validation error message
  • Database Seeder
  • Database Seeder With Relationship
  • Display Image Storage Folder
  • Display Validation Error
  • Eloquent
  • Fake Data
  • force Http to Https
  • Get User Location
  • Google Recaptcha V3
  • Helper Function
  • IP Address
  • Laravel
  • Laravel 12
  • Laravel Conditional Validation
  • laravel custom conditional validation
  • laravel custom validation
  • laravel custom validation parameters
  • Laravel Debugbar
  • Laravel Delete File
  • Laravel Eloquent
  • Laravel File Handling
  • laravel multiple image upload
  • Laravel Summernote Image Upload
  • migration
  • multiple orwhere condition
  • Restrict IP
  • Rollback
  • RouteServiceProvider Configuration
  • select2
  • select2 with ajax
  • Socialite Login
  • sometimes vs nullable
  • stevebauman/location package
  • Storage Folder
  • summernote
  • SweetAlert2
  • SweetAlert2 Delete Confirmation
  • Sweetalert2 with Ajax
  • Toastr Notifications
  • UUIDs
Logo
  • About Us
  • Contact Us

© 2025 All Rights Reserved

  • Disclaimer
  • Privacy Policy