Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel remember me not working

I have created 2 different login forms for admin and users in admin login form i have used attempt function i want to use remember me functionality but when i log in to the system without clicking remember me checkbox i can see in database it stores some value is it normal that its storing values not checking remember me token ? this is my code for admin login

 if (Auth::guard('admin')->attempt(['email' => $request->email, 'password' => $request->password], $request->remember)) {
    // if successful, then redirect to their intended location
    return redirect()->intended(route('admin.dashboard'));
  }

can someone please help me with remember me functionality in laravel

like image 975
Pranav Mandlik Avatar asked Mar 12 '18 10:03

Pranav Mandlik


1 Answers

Try passing boolean value as second parameter to method attempt , or

if (Auth::viaRemember()) {
   //
}

use viaRemember in new laravel versions

also , check your config/session.php setting

'lifetime' => 10080,
'expire_on_close' => true,

just set your expire_on_close to true and Auth with Auth::viaRemember()

hope this is helpful

like image 106
siddhant sankhe Avatar answered Oct 16 '22 21:10

siddhant sankhe