简体   繁体   中英

check if a user with specifc id is logged in or not laravel 5.2

How do I check if a specific user is logged in or not?

Auth::check() or Auth::user()->id

will not work as I need to check the user with specific user id like I want to check if a user with id = 53 is logged in or not then what Laravel auth function can I use

I have a middleware so would this be like Auth::guard('provider')->id?

You could potentially use the database session driver, which would also be storing the user_id with the session data. You could look for a record in the sessions table by user_id and based on the last_activity field roughly determine they are "logged in".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM