I am trying to replace a rather clumpsy ajax-login of Magento from an external site. The site uses Magento as a shop. Both the site and the magento-shop has their own logins, therefor when a user logs in it is important that both are synchronized. This was done with an ajax-call each page reload, keeping the user logged into Magento. I want to remove this so I created a check on each page reload which will do everything server-side.
My problem is, the following code does not work properly:
//Get Magento session-object
Mage::getSingleton("core/session", array("name"=>"frontend"));
$session = Mage::getSingleton("customer/session", array("name"=>"frontend"));
//Check if logged in
if(!$session->isLoggedIn()){
//Not logged in, therefor log in
$mpassword = $this->getMagentoPassword();
$musername = $this->getAddress();
try
{
$session->login($musername, $mpassword);
}catch(Exception $e){
echo $e->getMessage();
}
}
Looking at cookies, there aren't any created, the ajax-login actually made a "frontend"-cookie. I know the code above actually logs in a user, but there aren't any session cookies created. Any suggestions?