Skip to content

Instantly share code, notes, and snippets.

@fballiano
Created November 18, 2015 16:44
Show Gist options
  • Save fballiano/a2dabf4fecbe7cab8274 to your computer and use it in GitHub Desktop.
Save fballiano/a2dabf4fecbe7cab8274 to your computer and use it in GitHub Desktop.
<?php
define('MAGENTO', realpath(dirname(__FILE__)));
require_once MAGENTO . '/app/Mage.php';
Mage::app();
umask(0);
Mage::app('default');
Mage::getSingleton('core/session', array('name' => 'adminhtml'));
$user = Mage::getModel('admin/user')->loadByUsername('admin'); // Here admin is the Username
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()) {
$redirectUrl = Mage::getSingleton('adminhtml/url')->getUrl(Mage::getModel('admin/user')->getStartupPageUrl(), array('_current' => false));
header('Location: ' . $redirectUrl);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment