Back to Top

How to check user is logged in Modx

Here is one quick article to check whether a web user is logged in or not in Modx Revolution.

When you’re building the application, you want to load some pages after the user is logged in and if the user is not logged in, you need to redirect the user to login page.

MODX Revolution is a robust and flexible content management framework.I am going to explain that to check the user is logged in within the Modx Revolution.

In Modx Revolution, you can check the whether the user is logged in by the following code.

$user = $modx->getLoginUserName();

if ($user) {
	//Logged in user desired code
}else{
	//redirect to login page.
}

In above,getLoginUserName() determines if user is logged in by admin panel or frontend.Returns a User Name of the current user. If no user is logged in, null is returned by the function.

That’s it.I hope this post will help you. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

How to create Object Copy in PHP

Posted on 7 years ago

Bhumi

MySQL FULLTEXT Index and Search

Posted on 3 years ago

Bhumi

Cursor in IndexedDB API HTML5

Posted on 4 years ago

Bhumi

How to connect to MySQL database using PHP

Posted on 6 years ago

Bhumi

Hello world

Updated 5 days ago

Nick Carter

In depth Understanding of Laravel Core

Updated 2 months ago

Bhumi

ECMAScript 6 New Features – 2

Updated 1 year ago

Bhumi

The Reader’s Poll – June 2015

Posted on 4 years ago

Bhumi

The Reader’s Poll – August 2014

Posted on 4 years ago

Bhumi

The Reader’s Poll – June 2014

Posted on 5 years ago

Bhumi

The Readers’ Poll – May 2014

Posted on 5 years ago

Bhumi

The Readers’ Poll – August 2013

Posted on 5 years ago

Bhumi