samedi 29 avril 2017

Laravel 5 remember me not working

I am unable to get Laravel rememeber me functionality to work.

I added remember token column to my User Model table. My User Model Authenticatable. User model doesn't contain anything else specific related to remember me functionality

I am using default Auth drivers and guard.

My Usercontroller is different from default one. It extends from Controller. It doesn't use any Traits. In my login method, I use Auth::login($userModelObject, true) to login user. Everything works fine. Remember me token gets updated in database. I can see 3 cookies on browser XSRF-TOKEN, laravel_session, remember_web_59ba36addc2b2f9401580f014c7f58ea4e30989d.

Auth::check() returns true as expected but if I either remove, expires, or modify laravel_session, in the subsequent request, remember_web_59ba36addc2b2f9401580f014c7f58ea4e30989d cookie also gets removed for some reason (I am not able to view i$t using var_dump($_COOKIE) in only middleware I applied) and I think that's why Laravel Auth driver isn't able to use remember me Cookie to autologin user. CSRF middleware is also being applied automatically by Framework.

What could be causing this behaviour? Do I need to use some Additional Traits on my User Model or Controller?

Note: I am using Laravel 5.4 and my session config are:

'driver' => env('SESSION_DRIVER', 'file'),
'lifetime' => 20,
'expire_on_close' => false,
'encrypt' => false,
'files' => storage_path('framework/sessions'),
'connection' => null,
'table' => 'sessions',
'store' => null,
'lottery' => [2, 100],
'cookie' => 'laravel_session',
'path' => '/',
'domain' => env('SESSION_DOMAIN', null),
'secure' => env('SESSION_SECURE_COOKIE', false),
'http_only' => true



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2qiqkrF
via IFTTT

Aucun commentaire:

Enregistrer un commentaire