Creating authenticate in 2.x

I create simplest authenticate based on other model then User.

App::uses('BaseAuthenticate', 'Controller/Component/Auth');

class ClientAuthenticate extends BaseAuthenticate {

	public function authenticate(CakeRequest $request, CakeResponse $response) {
             // return user array...
	}
}

First login is okey, but:

  • click on any page or refresh window my logged user lost;
  • after login AuthComponent::user() is empty;

If I understood, this works that:

  1. I prepare _findUser function to return user array;
  2. authenticate firstly using _findUser if it’s user array, then logged;
  3. Any page or refresh using getUser for chcek logged user, based on _findUser… but in getUser don’t know username and password data…

Just a hint: check your session’s expirity. I have run into an issue with similar symptomps with controller authenticate. The source of the problem was incorrect time settings in PHP or Apache. Because of this my session expirity was always in the past.