How to implement user login in Zend Framework 2?
2 answers
When the browser submits the completed form to the server, you can get the posted values ββwith your controller like this:
$username = $this->params()->fromPost('username');
$password = $this->params()->fromPost('password');
Then you need to pass these values ββto whatever authentication mechanism you want to use. For example, you can do a simple database search with your custom table.
However, life is not easy. You need to think about security. Validation and filtering of values ββsubmitted from the form, hashing passwords, etc.
You also need to think about how to handle the invalid login, such as re-rendering the form with an additional display explaining the failure. Zend \ Form can help you with some of these problems.
+3
source to share