Cakephp 2x用户登录如何在形式cakephp之外卷曲。
成功登录后,我想获取登录用户详细信息或登录未成功获取消息“登录失败”
这是我的cakephp目录
cakephp->app
cakephp->demo
在我的代码下面:
演示/ index.php的
$urltopost = "http://localhost/eventapp/users/androide_login";
$fields = array(
'User'=>array(
'username' => 'demo',
'password' => '123456789'
)
);
$fields_string = http_build_query($fields);
$ch = curl_init ($urltopost);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, false);
$returndata = curl_exec ($ch);
curl_close ($ch);
print_r($returndata); //display the reuslt*/
这是我的UsersController /登录操作
public function androide_login() {
if ($this->request->is('post')) {
if ($this->Auth->login($this->data)) {
$user = $_SESSION['Auth']['User'];
pr($this->Session->read('Auth.User'));
die;
}
else {
$this->Session->setFlash('Your username or password was incorrect.');
}
}
}
关于代码无法正常工作。