Cakephp 3アプリケーションウィジェットにはログイン機能があります。ログイン機能は私のローカルマシン上で完璧に動作します。しかし、プロダクトサーバーでは、ログイン資格情報がcorrcetであると、指定したURLではなく、「\」にリダイレクトされます。私はそれがSessionの問題だと信じています。何らかの理由でセッションがリダイレクションラインで失われたということです。
コード:のAppControllerの
Initilaize方法
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->loadComponent('Auth',[
'authenticate'=>[
'Form'=>[
'fields'=>[
'username'=>'username',
'password'=>'password'
],
'finder' => 'auth',
]
],
'loginAction'=>[
'controller'=>'Users',
'action'=>'login'
],
'loginRedirect' => [
'controller'=> 'Pages',
'action'=> 'dashboard'
],
]);
}
UserController.php:
class UsersController extends AppController {
public function initialize()
{
parent::initialize();
}
public function login() {
if ($this->request->is('post')) {
$user=$this->Auth->identify();
if($user) {
$this->Auth->setUser($user);
return $this->redirect($this->Auth->redirectUrl());
} else {
$this->Flash->error(_('your username or password is incorrect, please try agian'), [
'key' => 'falseSignIn']);
}
}
}
public function logout() {
return $this->redirect($this->Auth->logout());
}
}
ここはphpinfo()を使った私のセッション情報です。
![enter image description here](https://i.stack.imgur.com/yKOxf.png)
loginredirectを定義したappコントローラの初期化機能を表示できますか? – Aparna
私は主な質問に追加しました。どうぞご覧ください – Tanan