public function login($username, $password, $expire = 0)
{
if ($this->_userManager->validateUser($username, $password)) {
if (($user = $this->_userManager->getUser($username)) === null) {
return false;
}
$this->updateSessionUser($user);
$this->getApplication()->setUser($user);
if ($expire > 0) {
$cookie = new THttpCookie($this->getUserKey(), '');
$cookie->setExpire(time() + $expire);
$this->_userManager->saveUserToCookie($cookie);
$this->getResponse()->getCookies()->add($cookie);
}
return true;
} else {
return false;
}
}