CakePHP2.4登录和重定向在服务器上不起作用

CakePHP2.4登录和重定向在服务器上不起作用,cakephp,authentication,redirect,login,Cakephp,Authentication,Redirect,Login,我正在使用cakePHP构建一个网站。登录功能在本地运行良好,但在我将它们发布到服务器后,我无法使用现有用户名和密码登录。该页面既不允许我登录,也不给我一条错误消息,应该在出现问题时显示该消息。我在stackoverflow中尝试了几乎所有的解决方案,但都无法解决。这是我的密码 型号: class User extends AppModel { public function beforeSave($options = array()) { /* password hashing */

我正在使用cakePHP构建一个网站。登录功能在本地运行良好,但在我将它们发布到服务器后,我无法使用现有用户名和密码登录。该页面既不允许我登录,也不给我一条错误消息,应该在出现问题时显示该消息。我在stackoverflow中尝试了几乎所有的解决方案,但都无法解决。这是我的密码

型号:

class User extends AppModel {


public function beforeSave($options = array()) {

/* password hashing */    
if (isset($this->data[$this->alias]['password'])) {
    $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
}
return true;
}
}
AppController:

class AppController extends Controller {

public function webroot() {

}

public $components = array('DebugKit.Toolbar','Session',
    /* add Auth component and set  the urls that will be loaded after the login and logout actions is performed */
    'Auth' => array(
        'loginRedirect' => array('controller' => 'Home', 'action' => 'index'),
        'logoutRedirect' => array('controller' => 'users', 'action' => 'login')
    )
);

public function beforeFilter() {
    /* set actions that will not require login */
    $this->Auth->allow('index','display', 'view');
}

}
class UsersController extends AppController {

public $components = array('Auth');

public function beforeFilter() {
     parent::beforeFilter();
$this->Auth->allow('add', 'logout');
}

public function login() {
    if ($this->request->is('post')) {
        /* login and redirect to url set in app controller */
        if ($this->Auth->login()) {
            return $this->redirect($this->Auth->redirect('/Home'));
        }
        $this->Session->setFlash(__('Invalid username or password, try again'));
    }
}

public function logout() {
     /* logout and redirect to url set in app controller */
    return $this->redirect($this->Auth->logout());
}
 public function index() {
    $this->User->recursive = 0;
    $this->set('Users', $this->paginate());
}

public function add() {
    if ($this->request->is('post')) {
        $this->User->create();
        if ($this->User->save($this->request->data)) {
            $this->Session->setFlash;
            return $this->redirect(array('controller' => 'Home','action' => 'index'));
        }
        $this->Session->setFlash(__('The user could not be saved. Please, try again.'));
    }
}
}
用户控制器:

class AppController extends Controller {

public function webroot() {

}

public $components = array('DebugKit.Toolbar','Session',
    /* add Auth component and set  the urls that will be loaded after the login and logout actions is performed */
    'Auth' => array(
        'loginRedirect' => array('controller' => 'Home', 'action' => 'index'),
        'logoutRedirect' => array('controller' => 'users', 'action' => 'login')
    )
);

public function beforeFilter() {
    /* set actions that will not require login */
    $this->Auth->allow('index','display', 'view');
}

}
class UsersController extends AppController {

public $components = array('Auth');

public function beforeFilter() {
     parent::beforeFilter();
$this->Auth->allow('add', 'logout');
}

public function login() {
    if ($this->request->is('post')) {
        /* login and redirect to url set in app controller */
        if ($this->Auth->login()) {
            return $this->redirect($this->Auth->redirect('/Home'));
        }
        $this->Session->setFlash(__('Invalid username or password, try again'));
    }
}

public function logout() {
     /* logout and redirect to url set in app controller */
    return $this->redirect($this->Auth->logout());
}
 public function index() {
    $this->User->recursive = 0;
    $this->set('Users', $this->paginate());
}

public function add() {
    if ($this->request->is('post')) {
        $this->User->create();
        if ($this->User->save($this->request->data)) {
            $this->Session->setFlash;
            return $this->redirect(array('controller' => 'Home','action' => 'index'));
        }
        $this->Session->setFlash(__('The user could not be saved. Please, try again.'));
    }
}
}
视图:


页面没有[]给我错误消息您的呼叫和会话->flash呼叫使用不同的键/元素-默认为默认值。但在服务器上,它不会重定向,这可能表明您在某个文件的开头有空格,并且没有会话,并且您无法重定向,因为已经发送了标题-检查您的app/tmp/error.log文件。还有公共函数webroot{谢谢你的重播。我搜索了很多关于空白的解决方案,我确实找到了一些,我把它们处理掉了,但仍然不起作用。正如你所说,我还检查了error.log,我发现每次单击登录按钮时都会发生此错误:2014-05-14 05:16:21错误:[MissingActionException]找不到Action UsersController::js。异常属性:数组'controller'=>'UsersController','Action'=>'js',太长了,所以我在帖子中编辑了。请检查。UsersController::js或'controller'=>'UsersController','Action'=>'js'是我甚至没有编码的内容。我完全迷路了。请求URL:/users/js/lightbox、 min.js