开发者

Cakephp Auth component malfunctioning

I got trouble with auth component in cakephp, on ovh host.

When i log in, no session variable are set : print_r($this_session) only show :

Array ( [Config] => Array ( [userAgent] =>开发者_开发百科; [time] => 1302122401 [timeout] => 10 ) )

The weird part of this issue, is that sometimes it works... I used to connect correctly from my house, less from my work.

Here is the code i use. It really simple. One app_controller :

<?php
class AppController extends Controller {
        var $components = array("Session","Auth");
        function beforeFilter() {
                $this->Auth->fields = array('username' => 'name', 'password' => 'password');
                $this->Auth->loginAction = array('action' => 'login');
        $this->Auth->loginRedirect = array('controller' => 'discs', 'action' => 'hello');
        $this->Auth->logoutRedirect = '/';
                $this->Auth->loginError = 'Invalid name / password combination.  Please try again';
        }
}

?>

In user_controller :

function login() {
           }

    function logout() {
    $this->redirect($this->Auth->logout());
    }

I try to modify the sessions configuration : - trying php or cake managed - trying security level from low to medium - trying to change the session cookie name - trying set checkAgent to false.

Any idea ?


I'm not sure, but I guess your code is already correct. I've noticed the file name 'user_controller'. Is that user_controller instead of users_controller? naming convention in cakephp is really important for us to prevent such errors. Lastly, try to remove $this->Auth->loginAction = array('action' => 'login');.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜