Jan 01

October Cms access logged in user rainlab user plugin

In the October cms, you can easily access logged-in user data using Rainlab.user plugin's Auth facade and get current login user details.

To check if the user is logged in or not you can use the below code

check if user is logged in or not
use Auth;

// it will return true if user is logged in
$loggedIn = Auth::check();

If you need logged-in user details you can use below code

Always make sure user is logged in, after that you can use logged in user data
get logged-in user details
use Auth;

// it will returns the current logged in user
$user = Auth::getUser();