2

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

2

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.

<?php
require_once 'app/Mage.php';
umask(0);
$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()) {
  Mage::getSingleton('adminhtml/url')->renewSecretUrls();
}

$session = Mage::getSingleton('admin/session');
$session->setIsFirstVisit(true);
$session->setUser($user);
$session->setAcl(Mage::getResourceModel('admin/acl')->loadAcl());
Mage::dispatchEvent('admin_session_user_login_success',array('user'=>$user));

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

Source:

  • Not working it display "logged in" on page but when i open admin panel, it display login page. – Mathew Oct 20 '15 at 6:53
  • Instead of echoing try actually redirect to the admin URL instead? – B00MER Oct 20 '15 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 '15 at 7:17

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.