0

我想将 Magento 数据库与我的其他网站连接以进行登录。使用户无需再次注册。

对于其他网站,我没有 Magento 层。只是原始的 PHP mysql 网站。

我想知道创建中央数据库的最佳方法是什么,以及如何从 Magento 数据库中检索用户信息(仅限用户名和密码。)。

我正在考虑执行原始的 php mysql 查询,但为此我需要在我的服务器上打开端口以连接到其他服务器,因为所有网站都在不同的服务器上。

什么是最好的方法。

4

1 回答 1

0

为了实现 SSO(单点登录),最好的办法是将所有用户迁移到 Magento。

Magento 文件也应该可以在外部网站上访问(如果它们在同一台服务器上或通过挂载。)然后您可以使用类似以下代码的内容:

<?php

require_once '/path/to/magento/root/app/Mage.php';
umask(0);
Mage::app();

$session = Mage::getSingleton('customer/session');

// Login
try {
    $session->login($email, $password);
    $session->setCustomerAsLoggedIn($session->getCustomer());

    //Load the customer modules
    $customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId());

    //Get customer attribbutes
    $customer->loadByEmail($email);

} catch (Exception $e) {
    Mage::log($e->getMessage());
}

其中 $email 和 $password 将包含从表单发送的值

于 2012-06-26T07:40:20.183 回答