MongoDB Authentication Using PHP
Recently, a client of mine wanted to have an authentication system for their existing Web Application. They are currently using MongoDB as their Database and just wanted to implement a simple Login, Register and Account page for their customers.
I did not have much experience working with MongoDB before I accepted the project so I struggled a little bit figuring out a way to make an authentication work with MongoDB, but soon after – I realized that the focus of the logic should be on PHP itself, not MongoDB. So then I started coding until I finally finished a simple session based authentication.
Instead of pasting the entire code in this page, I decided to put the project on Github.
- Registration page
- Easy to scale fields.
- Login and redirects on success
- Login Page
- Redirects on succes
- Account Page
- It simply displays the information of the user.
- Returns true if the user is logged in, otherwise it returns false.
- Returns an object containing data of the currently logged in user.