How Remember me Function Work at Login Option in Laravel?

Today now in this post we will know about how remember me function work at login option in laravel? Most of us always use remember me option in our login page, on that way any user don’t need to login every times. So, we can use remember me option in our project login page then we can also do this simply, because on laravel provide it’s own functionality. But, many developers can’t do this properly i mean remember me is not working, but we can implement it right.

So at first you have to sure that remember_token field in your users table. if you haven’t remember_token column then at first need to add it in your users table or any table that you use as for the authantication.

Now you should have a controller method on this way:

public function webLoginPost(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.');

Read Also :Laravel Join with Subquery in Query Builder Example

Thanks for read. I hope it help you. For more you can follow us on facebook.


About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →