Moving cakephp 2.7.3 code from localhost to hosting server

I am a new cakephp-developer and completed my first application on localhost. I have uploaded it to hosting server. On host server, new user is getting registered in database but login is not working. Issue is $this->Auth->login() returns false and hence no redirection happening. Any help on this can help me to continue learning cakephp.

So log in works fine on localhost but doesn’t on the server, even though everything else works? That’s strange.

Have you checked the cake error logs and the php server logs? Anything in there?

Have you made any special configurations to core.php?

Are sessions working okay on the server otherwise?

It’s also possible that something wasn’t uploaded properly to the server, maybe try reuploading the files.

No errors in error logs.
No special settings in core.php
Sessions are working in other application on server.
reuploaded all files but no luck so far.

Can you debug the post data in the login method to make sure it’s being submitted correctly?

You could also try a manual login by adding the user data as a variable to the login function.

Other than that, you should post your auth configuration and login method in here. There’s really nothing to go by otherwise, and it’s not a common issue as far as I know.

Please find below are my Controller functions.


App::uses(‘Controller’, ‘Controller’,‘MerchantDetail’);
App::uses(‘CakeEmail’, ‘Network/Email’);

class AppController extends Controller {
public $uses = array(‘MerchantDetail’);
public $components = array(‘Auth’,‘Session’);
public $helpers = array(‘Cache’, ‘Html’, ‘Form’, ‘Session’);

public function beforeFilter() {		
	ini_set('memory_limit', '-1');
	if($this->request->prefix == 'admin') {
		AuthComponent::$sessionKey = 'Auth.Admin';
		$this->layout = 'admin';
		$this->Auth->loginAction = array('controller'=>'administrators','action'=>'login');
		$this->Auth->loginRedirect = array('controller'=>'administrators','action'=>'dashboard');
		$this->Auth->logoutRedirect = array('controller'=>'administrators','action'=>'login');
		$this->Auth->authenticate = array(				
			'Form' => array(
			   'userModel' => 'MerchantDetail'
			   , 'passwordHasher' => 'Simple'
			   ,'fields' => array('username' => 'email', 'password' => 'password')  // newly added
	} else {
		/* do another stuff for user authentication */

public function isAuthorized($user){
	return true;


Functions inside AdministratorsController

`public function beforeFilter() {


public function admin_login() {
	echo "admin_login";
	if ($this->Auth->loggedIn()) {
	    return $this->redirect($this->Auth->redirect());
	echo "check is post";
		echo "inside post";			
	if ($this->Auth->login()) {
			echo "redirecting";
            return $this->redirect($this->Auth->redirect());
        } else {
        	echo "redirect failed";
            $this->Session->setFlash('Username or password is incorrect.','error');

The above code gives me the following output when I try to login.

admin_logincheck is postinside postArray ( [MerchantDetail] => Array ( [email] => jj@jj.jj [password] => 123 ) ) redirect failed

It might be very silly mistake somewhere but I am not getting it.

Yes, well, this behavior is exactly what you would expect if the password and / or username are not correct.

I suspect it is related to the hashing of the password somehow, but I don’t have a clear idea what could be the issue at the moment :frowning:

I don’t see anything wrong with the code itself, though, hmm…