I am working on the script for the login of admin panel automatically into the admin panel. Here is code link which is used for automatically login admin user into the admin panel. But it is not working when I run simple code then it says authenticated but it is not login into admin area when I open admin then it lands to login page only. I also googled script and find this code see an image. In the block, I get my conditions but as I move to Magento page then again login page is present. Is this process is possible or not with customization.

enter image description here

1 Answer 1


Looks like your source, pretty much lifted my original SO Answer.

With that said be sure and make sure the secretKey info is being set and other session methods are defined and dispatching any events or else it won't work.

require_once 'app/Mage.php';
$app = Mage::app('default');

Mage::getSingleton('core/session', array('name' => 'adminhtml'));

// supply username
$user = Mage::getModel('admin/user')->loadByUsername('adminusername');

if (Mage::getSingleton('adminhtml/url')->useSecretKey()) {

$session = Mage::getSingleton('admin/session');

if ($session->isLoggedIn()) {
  echo("logged in");


  • Not working it display "logged in" on page but when i open admin panel, it display login page.
    – Mathew
    Oct 20, 2015 at 6:53
  • Instead of echoing try actually redirect to the admin URL instead?
    – B00MER
    Oct 20, 2015 at 6:54
  • 1
    Redirection is also not working. I dont understand only echo is working but as i redirect magento login page it display only login page.
    – Mathew
    Oct 20, 2015 at 7:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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