Via Remember me always return false

社会主义新天地 提交于 2019-12-12 10:14:21

问题


Before I posted this, I did some searching but still I don't know it always return false. My code is below

html

<input type="checkbox" name="remember"/> {{ trans('login.text_remember_me') }}

controller

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

if (Auth::attempt($credentials, $remember))

Then after successful logged-in. I checked the dd(Auth::viaRemember()); and it return false. Even changed my config/session.php setting 'expire_on_close' => true from false.

Basically what I want is when the user tick the remember me checkbox I will set the session lifetime to 3 days else to 1 day only.

Updated

From $request->all() here are the result after clicking the login button with checked remember me

array:6 [▼
  "_token" => "...."
  "email" => "myemail@gmail.com"
  "password" => "...."
  "remember" => "on"
  "uri" => ""
  "code" => ""
]

then I removed in my dashboard controller I checked the viaRemember method

dd(Auth::viaRemember()); // result: false

回答1:


Update your this line

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

to this, and then check.

$remember = ($request->get('remember') == 'on') ? true : false;



回答2:


add "id = remember me" to input field

<input type="checkbox" name="remember" id="remember"/> 

not sure.



来源:https://stackoverflow.com/questions/39885982/via-remember-me-always-return-false

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!