Sometimes we need a login system in our laravel application with remember me functionality. But many times developer face problems like laravel remember me not working. So I am here to show you the example of laravel remember me token example.

I will share the source code of laravel remember me token so that you can implement laravel login system with remember me. 

First, we need the remember_token field in our users table. if you do not have remember_token column then first add it to your users table or any table that you use for auth.

Now, update the LoginController with the following code: 



namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class LoginController extends Controller
  public function login(Request $request)
    $this->validate($request, [
       'email' => 'required|email',
       'password' => 'required',

    $remember_me = $request->has('remember_me') ? true : false; 

    if (auth()->attempt(['email' => $request->input('email'), 'password' => $request->input('password')], $remember_me))
        $user = auth()->user();
        return back()->with('error','your username and password are wrong.');



Now we know login system with remember me. Hope this laravel remember me with login tutorial will help you.

Category : #laravel

Tags : #laravel , #laravel auth