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 ("magento\app\Mage.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?
Visit your Magento admin backend in a browser, and click the link Forgot your password. Insert your email address, complete the CAPTCHA, and then press on the Retrieve Password button. An email will be send to your email address, containing a password reset link.
<?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");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With