Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
407 views
in Technique[技术] by (71.8m points)

Laravel 5.4 AUTH - Auth::guard('admin')->user() 登陆后其他页面取出来为NULL

登录时使用

Auth::guard('admin')->attempt([])

返回了true,然后用dd打印

dd(Auth::guard('admin'))

clipboard.png

本页面的登录是可以的。然后跳转到其他页面时,再打印一次

clipboard.png

这时因为user属性为空,所以

Auth::guard('admin')->user() == null
Auth::guard('admin')->check() == false

请问是哪个步骤出了错


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

很久的问题了,忘了确认,今天确认一下(年代久远,一些细节记不清了)
首先确认session 和 cookie 正常,然后再到登录表中加入

use IlluminateAuthAuthenticatable;

即可,如果还不行,请结合自己代码研究


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...