I use the code below to login and redirect to the account page:
<?php include('store/app/Mage.php'); Mage::app(); if($_POST && $_POST['login']['username'] && $_POST['login']['password']){ $email = $_POST['login']['username']; $password = $_POST['login']['password']; $session = Mage::getSingleton('customer/session'); try { $log = $session->login($email, $password); $session->setCustomerAsLoggedIn($session->getCustomer()); $customer_id = $session->getCustomerId(); $send_data["success"] = true; $send_data["message"] = "Login Success"; $send_data["customer_id"] = $customer_id; Mage::getSingleton('customer/session')->loginById($customer_id); Mage_Core_Model_Session_Abstract_Varien::start(); }catch (Exception $ex) { $send_data["success"] = false; $send_data["message"] = $ex->getMessage(); } }else { $send_data["success"]=false; $send_data["message"]="Enter both Email and Password"; } echo json_encode($send_data); ?>
And then in the file where I am making the ajax request, I use this code:
if(data.success){ window.location = "http://domain.com/store/customer/account/" }
But it always displays the user as logging out, although I get the correct client ID as well as success.
source share