cancel
Showing results for 
Search instead for 
Did you mean: 

How to call customer login form out side of Mage

SOLVED

How to call customer login form out side of Mage

 

Hi,

 

I have to call Customer login from from out side of magento setup

Like www.demo.com is my Mage  setup

I have one more core php website

when i have login from www.demo.com/core/login.php 

needto login magetno setup also.

Eg;

include ("../app/mage.php");
umask(0);
Mage::app();
<form id="login-form" method="post" action="http://127.0.0.1/demo/customer/account/loginPost/">
<input type="hidden" value="<?php echo $fromKey; ?>" name="form_key">

<input type="text" title="Email Address" class="input-text required-entry validate-email" id="email" value="" name="login[username]">

<input type="password" title="Password" id="pass" class="input-text required-entry validate-password" name="login[password]">
<input type="submit" value="login"/>

when i copy from Mage login form.

login is showing error like

 

Cannot send headers; headers already sent

 

but user is loged in success.
because of fromkey()

1) i created new form key by
Mage::getSingleton('core/session')->getFormKey();

uts redirecting to login page or showign eable cookies.

 

Mage::getSingleton('core/session')->setData('_form_key', Mage::helper('core')->getRandomString(16))->getFormkey();

not login 

my Question is 

1) how to login from out side

2) why new fromKey() not allowing to me login but when copy login.phml formkey its working. or how to call login form out side.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to call customer login form out side of Mage

So, you are doing this how?

 

I have PHP code to automatically log someone in to Magento, looks something like this.

Mage::app();
Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('customer/session');
$session->login($_POST['EmailAddress'],$_POST['Password']);
$session->setCustomerAsLoggedIn($session->getCustomer());

 

View solution in original post

3 REPLIES 3

Re: How to call customer login form out side of Mage

So, you are doing this how?

 

I have PHP code to automatically log someone in to Magento, looks something like this.

Mage::app();
Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('customer/session');
$session->login($_POST['EmailAddress'],$_POST['Password']);
$session->setCustomerAsLoggedIn($session->getCustomer());

 

Re: How to call customer login form out side of Mage

Hi MrBaseball34, Thanks for your Ans,

 I have small query 

Why when I was used 

$fromKey = Mage::getSingleton('core/session')->getFormKey();

Its login is working but its showing fatal error.

 

I crated my 

$newFormkey = Mage::getSingleton('core/session')->setData('_form_key', Mage::helper('core')->getRandomString(16));

$newFormkey its working good no errors.

 

waht is different btw both formkeys.

why its not working noremal formkey.

Re: How to call customer login form out side of Mage

We don't use forms for this, it is in an ExpressionEngine plugin. I am not sure how to use the encrypted forms in Magento.