pwfans

Detect admin login

Recommended Posts

Is there any builtin session created automatically when admin logged in ?

Currently i do this way to detect admin login or not;
- Install core module Session Handler Database, i can see in database when admin login/logout
- Because i don't know whats API to use to to fetch above data, i'm using $db->query("select  .. from .. where")
- From query result above i can make if statement admin logged do this, else do that for any page, eg: prevent opening certain page if admin not login.

Anyone knows what API to use to handle that process ? thank you

Share this post


Link to post
Share on other sites

Thank you, what stupid i am ! 😫

$user->isSuperuser()

Yes, this one work ! thank you.

if ($user->isSuperuser()) {
	echo "do this";
} else {
	echo "do that";
}

Mean: if current user login has superuser role, do this.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.