我正在使用CakePHP启动项目,我正在尝试了解登录过程,然后创建一个包含登录/用户字段的会话:
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))));
}
此时我想从用户字段创建一些会话变量并在会话中设置它们:
//Setting Session Variables:
$this -> Session -> write( "name", $users['User']['fname'] . " " . $users['User']['lname']);
//Retrieving Session Variables:
echo $this -> Session -> read("name");
但是我在设置会话变量的最后一部分时遇到了麻烦。
问题:
如何为用户设置会话变量?
任何帮助赞赏的人......