The problem is that the function setUser in usersController is returning null, and doesn't login the user.
The query to DB is getting the user, and i can see the fields without problems. The session file in /tmp/sessions is created ok & if we change the config to php session, not cake, is creating that too.
Seems like the session has been created but apache or cake can't read that.
The same code, in different OS & php version works fine.
Can be related with some specific permissions for www-data/apache users ?
We're running Apache2, php 7.3 & connecting to SqlServer.
CODE:
//////////////////////////////////////
AppController.php
ini_set(‘allow_url_fopen’, ‘on’);
$this->loadComponent(‘Auth’, [
‘loginRedirect’ => [ ‘controller’ => ‘/’, ‘action’ => ‘home’],
‘logoutRedirect’ => [ ‘controller’ => ‘/’, ‘action’ => ‘login’],
‘authenticate’ => [
‘Form’ => [
‘fields’ => [‘username’ => ‘email’, ‘password’ => ‘password’],
‘userModel’ => ‘Usuarios’
]
],
‘storage’ => [‘className’ => ‘Session’, ‘key’ => ‘Auth.Usuario’],
‘loginAction’ => [ ‘controller’ => ‘/’, ‘action’ => ‘login’],
‘unauthorizedRedirect’ => $this->referer(),
‘authorize’ => ‘Controller’,
‘authError’ => false,
]);
$this->Auth->__set('sessionKey', 'Auth.Usuario');
///////////////////////////////////////
UsuariosController.php
public function login()
{
if($this->request->is(‘post’)){
$usuario = $this->Auth->identify();
if ($usuario) {
if($this->Auth->setUser($usuario)){
$this->Flash->sPublico(__('Ingresaste a tu cuenta.'));
return $this->redirect([
'controller' => 'Pages',
'action' => 'home'
]);
}else{
$this->Flash->ePublico(__('No se pudo acceder a la sesion!.'));
}
else{
$this->Flash->ePublico(__(‘Usuario y/o contraseña incorrectos!.’));
}
}
}
///////////////////////////////////////
$this->Auth->setUser($usuario),is the function that returns false :S
Thanks !