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
    • Validations
    • Easy to scale fields.
    • Login and redirects on success
  • Login Page
    • Validations
    • Redirects on succes
  • Account Page
    • It simply displays the information of the user.
  • Logout


  • is_user_logged_in();
    • Returns true if the user is logged in, otherwise it returns false.
  • current_user();
    • Returns an object containing data of the currently logged in user.

Do you need help with a project? or have a new project in mind that you need help with?

Contact Me