Is there a way in Laravel 5.7 to find out how much time a user has left before their current session expires?
EDITED
I also want to check when the current session expires for guests as well as logged in users.
Also, in the current answers, there seem to be conflicting ideas that a session will expire exactly "SESSION_LIFETIME" minutes after login, while others are thinking that the session expires after the last user activity. It would be good to clarify which is correct. Then also how to then get the last activity time and what classifies as activity on the session.
Also, I think Session::activity() has been removed in Laravel 5.7.
POSSIBLE SOLUTION
Thanks to @bharat-geleda below, this is a working solution if you are using Laravel 5.7 and storing sessions within the DB.
$last_activity = \DB::table('sessions')->select('last_activity')->where('id', session()->getId())->first()->last_activity;
$session_time_remaining_minutes = ($last_activity + (\Config::get('session.lifetime') * 60) - time()) / 60;
dd($session_time_remaining_minutes);
I'm currently unclear when 'last_activity' gets updated though, it isn't happening on page refresh.