2012-06-26 125 views
0

我想連接Magento數據庫與我的其他網站登錄的目的。這樣用戶不需要再次註冊。Magento數據庫競爭其他網站

對於其他網站我沒有Magento圖層。只是原始的PHP MySQL網站。

我想知道什麼是最好的方式創建一箇中央數據庫,以及如何從Magento數據庫檢索用戶信息(僅用戶名和密碼)。

我想執行原始php mysql查詢,但爲此我需要打開我的服務器上的端口連接到其他服務器,因爲所有網站都在不同的服務器上。

什麼是最好的方法。在此先感謝

回答

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()); 
} 

其中$電子郵件和$密碼將包含從表格發送的值

+0

它是否像我可以使用PHP掛載功能來使用外部文件位置?如果你能告訴我如何掛載,我可能不太適合linux或某些提示,因此可能是 – RIK

+0

。 – RIK

+0

我會嘗試一下tmr – RIK