一旦登录成功,我想通过curl发布magento管理员用户名和密码应该重定向到magento管理仪表板。 我该怎么做? 基本上magento登录需要以下信息:
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");
我该怎么办?
答案 0 :(得分:5)
<?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");
}