0

I am working on externally php + magento script.My requirement write a php code from which i get all online admin users.

Example:

Admin1 - Login - Action
Admin2 - Login - Action

And so on....

How can i achieve this by php script.I know to load magento app file in externally php file. Here action is logout script with the help of which i want logout admin user from this page.

1

Try this:

<?php
require_once('app/Mage.php');
Mage::app('admin');

class AR
{
    public function index()
    {
        Mage::getSingleton('core/session', array('name'=>'adminhtml'));

        //verify if the user is logged in to the backend
        if(Mage::getSingleton('admin/session')->isLoggedIn()){
            echo "Admin user is login";
        }
        else{
          echo "Admin user is not login";
        }

    }

}

$obj = new AR();
$obj->index();
?>
0

You can run Magento code from a standalone php file.

This comes in handy for creating external crons or for displaying Magento output in another package like WordPress.

First, you need to locate the app/Mage.php file and require it in your php file.

require_once ‘app/Mage.php’;

If your Magento installation is in a subfolder then you should include that path in the require statement.

require_once ‘YOUR_MAGENTO_FOLDER/app/Mage.php’;
umask(0);
Load Magento:
Mage::app(‘default’); # Note: This is “app” not “run”!

Now you can make calls to Magento objects

You may try this for your question

$userName = Mage::getModel('admin/session')->getUser()->getUsername();

Hope this may help You..:)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.