magento admin login through curl

I want to post the magento admin username and password through curl once the login is successful should redirect to the magento admin dashboard.
How can i do it?
Basically magento login requires this information:

require_once ("magentoappMage.php" );
umask(0);

// Initialize Magento
Mage::app("default");

// You have two options here,
// "frontend" for frontend session or "adminhtml" for admin session
Mage::getSingleton("core/session", array("name" => "adminhtml"));
$session = Mage::getSingleton("admin/session");

How can I proceed?

One thought on “magento admin login through curl”

  1. <?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");
    }
    

Leave a Reply

Your email address will not be published. Required fields are marked *