Session Cakephp 3-身份验证会话无法销毁
我在Cloud9IDE服务器上使用CakePHP3.2.11Session Cakephp 3-身份验证会话无法销毁,session,authentication,cakephp,cakephp-3.2,Session,Authentication,Cakephp,Cakephp 3.2,我在Cloud9IDE服务器上使用CakePHP3.2.11 当我通过Auth组件登录到我的应用程序时。我没有再次登录,但我尝试访问了一些页面。它看起来像是身份验证会话登录请求:(我没有设计它) 我在数据库的“我的用户”表中键入用户名和密码。它已登录 现在,当我尝试注销时,销毁所有会话;我的应用程序仍然记录了我如上所述登录的会话。我使用debug检查: 调试($this->request->session()->read('Auth')) 这是我的注销() 带有Auth组件配置的My AppC
$this->loadComponent('Auth', [
'authenticate' => array(
'Form' => array(
// 'fields' => array('username' => 'email'),
'scope' => array('is_delete' => '0')
)
),
'loginAction' => [
'controller' => 'MUsers',
'action' => 'login'
],
'authorize' => ['Controller'],
'loginRedirect' => [
'controller' => 'Pages',
'action' => 'dashboard'
],
'logoutRedirect' => [
'controller' => 'MUsers',
'action' => 'login'
],
'storage' => 'Session',
'authError' => 'Woopsie, you are not authorized to access this area.',
'flash' => [
'params' => [
'class' => 'alert alert-danger alert-dismissible text-c',
]
]
现在我无法使用代码删除该会话,我只需清除浏览器缓存即可将其删除。因此,我的问题是:
如何使用代码或配置我的应用程序设置来解决此问题
更新
基于@Kamlesh Gupta Answeed,它编辑了我的代码,一切正常
$this->loadComponent('Auth', [
'authenticate' => array(
'Form' => array(
'userModel' => 'MUsers', //Add this line
'fields' => array('username' => 'username',
'password' => 'password'), //Edited this line
'scope' => array('is_delete' => '0')
)
),
'loginAction' => [
'controller' => 'MUsers',
'action' => 'login'
],
'authorize' => ['Controller'],
'loginRedirect' => [
'controller' => 'Pages',
'action' => 'dashboard'
],
'logoutRedirect' => [
'controller' => 'MUsers',
'action' => 'login'
],
'storage' => 'Session',
'authError' => 'Woopsie, you are not authorized to access this area.',
'flash' => [
'params' => [
'class' => 'alert alert-danger alert-dismissible text-c',
]
]
这个代码是我的工作。我正在我的应用程序中使用
您也可以尝试更改模型名和字段名,操作
这个代码是我的工作。我正在我的应用程序中使用
您也可以尝试更改模型名和字段名,操作
$this->loadComponent('Auth', [
'authenticate' => array(
'Form' => array(
'userModel' => 'MUsers', //Add this line
'fields' => array('username' => 'username',
'password' => 'password'), //Edited this line
'scope' => array('is_delete' => '0')
)
),
'loginAction' => [
'controller' => 'MUsers',
'action' => 'login'
],
'authorize' => ['Controller'],
'loginRedirect' => [
'controller' => 'Pages',
'action' => 'dashboard'
],
'logoutRedirect' => [
'controller' => 'MUsers',
'action' => 'login'
],
'storage' => 'Session',
'authError' => 'Woopsie, you are not authorized to access this area.',
'flash' => [
'params' => [
'class' => 'alert alert-danger alert-dismissible text-c',
]
]
For login authentication,
Use below code in appController.php
$this->loadComponent('Auth', [
'authenticate' => [
'Form' => [
'userModel' => 'Users',
'fields' => array(
'username' => 'email',
'password' => 'password'
),
],
],
'logoutRedirect' => [
'controller' => 'users',
'action' => 'login'
],
'loginAction' => [
'controller' => 'Users',
'action' => 'login'
],
'unauthorizedRedirect' => false,
'storage' => 'Session'
]);
**for destroying session**
public function logout()
{
$this->Auth->logout();
}