What Is a Login System?
Imagine you have a clubhouse. The clubhouse has a door with a lock on it. Only people who have the key can get inside. That is what a login system does for a website. It is the lock on the door.
A login system lets a website recognise who you are. When you type your username or email address and your password, the website checks, "Do I know this person? Is this really them?" If yes, you are let in. If no, the door stays locked.
Why Do We Need One?
Without a login system, every visitor to your website would see everything. There would be no private areas. No way to have a "members only" section, no way to let people save their settings, and no way to know who is who.
A login system lets you build things like:
- A members area where only logged-in users can see special content.
- An admin panel where site managers can update the website.
- Account pages where users can change their name, email, or password.
- A shopping cart that remembers what a user put in it (because the website knows who they are).
How Does a Login System Work?
At its heart, a login system does three things:
- It checks your credentials. You give the website your username (or email) and your password. The website looks up your account and checks if the password is correct.
- It remembers you. Once the website confirms it is really you, it creates a little "token" - like a digital hand stamp. Every time you visit a new page, the website checks for that hand stamp. If it is there, you are let in.
- It forgets you when you leave. When you click "log out", the hand stamp is removed. The next time you visit, you will need to log in again.
What Trongate Does for You
Building a login system from scratch is a lot of work. You have to write code to check passwords, create tokens, remember users, handle forgotten passwords, and stop people from guessing passwords over and over again.
Trongate v2 comes with a login module that does all of this for you. You do not need to write any authentication code. You just need to:
- Tell Trongate what your database table looks like (a configuration file).
- Build a simple controller for your members (a few lines of code).
That is it. The login module handles the hard parts. The rest of this chapter will show you exactly how to set everything up.
What's Next
In the next page, we will look at the pieces you need - the database tables and the configuration file - and explain each one simply.
We're continually improving the Trongate documentation. If anything is incorrect, unclear, incomplete, or could be better, we'd genuinely appreciate your input.
Share your thoughts in the Documentation Feedback.