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.

Qaisar Satti
32.6k18 gold badges88 silver badges138 bronze badges
asked Oct 22, 2015 at 4:47

2 Answers 2

2

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();
?>
answered Jan 29, 2016 at 5:45
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..:)

answered Oct 22, 2015 at 7:45

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.