Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

magento admin login through curl

Tags:

php

magento

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?

like image 844
mark rammmy Avatar asked Feb 11 '11 19:02

mark rammmy


People also ask

How do I find my Magento admin username and password?

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.


1 Answers

<?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");
}
like image 139
B00MER Avatar answered Oct 04 '22 22:10

B00MER