Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Phalcon Authentication Issue [Note] This was actually an issue with me having my column length, in my users table, too short. Instead of 60 chars max, I had it at 50 chars max. DOH![/NOTE]
class SessionController extends \Phalcon\Mvc\Controller
public function indexAction()
// Will display users profile... once logged in
* Log in a current user and start session
public function startSessionAction()
$data = $this->request;
$username = $data->getPost('username');
$password = $data->getPost('password');
$user = Users::findFirstByUsername($username);
if($this->security->checkHash($password, $user->password)){
$this->persistent->name = $user->name;
$this->flashSession->success('Welcome ' . $this->persistent->name);
return $this->response->redirect('user/index');
$this->flashSession->error("The username you provided is not in our system.");
return $this->response->redirect('user/login');
$this->flashSession->error("Password does match our records for " . $user->username . " .");
return $this->response->redirect('user/login');
// Destroy Session
public function destroySessionAction()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.