Login Systems
Build secure registration, login, sessions, protected pages and user/admin role-based access with PDO.
Creating a User Database and Table Using SQL
A login system needs a users table that can identify accounts, store password hashes and enforce ...
Secure Password Storage with Password Hashing
Password hashing converts a password into a one-way value suitable for storage. PHP automatically...
Creating a User Registration Form
This standalone registration page accepts a fictional username and password, validates both on th...
Creating a Login Form
This standalone login page validates credentials with PDO, starts a secure session and redirects ...
Using PHP Sessions to Keep Users Logged In
PHP sessions store a small amount of trusted server-side state between requests. A login system c...
Protecting Pages and Preventing Unauthorised Access
A protected page checks authentication on the server before sending restricted content. Hiding a ...
Creating a Logout Page
Logout should remove server-side session data, expire the session cookie and return the user to a...
Adding Role-Based Access Control
Role-based access control allows authenticated users to perform only the actions permitted by the...
Creating a Navigation Menu Based on User Roles
Role-aware navigation shows users the actions available to them. It improves usability, but serve...
Protecting an Admin-Only Data Import Page
A role-based system must enforce permissions on the server. Hiding a link is helpful navigation, ...