开发者

CakePHP Login and Session Management

I am in the process of starting a project with CakePHP and I am trying to get an understanding for the login process, followed by creating a session that contains the login/user fields:

function login_php(){
    // -=> Retrieve form fields "u" and "p" (Username and password):
    $a = $this->params['form']['u']; //email address.
    $b = $this->params['form']['p']; //password.

    // -=> Query Retrieve User, match email and password fields:
    // -=> Make users data available in the view:
    $this->set('users', $this->User->find('all', array('conditions' => array('User.email =' => $a , 'User.password =' => $b))));
}

At this point I would now like to create a number of session variables from the users fields and set them in the session:

    //Setting Session 开发者_开发技巧Variables:
    $this -> Session -> write( "name", $users['User']['fname'] . " " . $users['User']['lname']);

    //Retrieving Session Variables:
    echo $this -> Session -> read("name");

But I am having trouble with this last part of setting the session variable.

QUESTION:

How do you set the session variables for the user?

Any help appreciated guys...


You are aware cake comes with an authentication module already in place, yes?

http://book.cakephp.org/view/1250/Authentication

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜