This video will be available to
subscribers on Thu, Jun 26, 2025.
You must be a subscriber to view this video.
Jun 26, 2025
9m:3s

User Authentication

Classification
Software Engineering | Languages | PHP
Keywords
oop | php

About This Episode:

πŸ“ Controller Setup
- Create a new AuthenticationController inside Http/ with three methods:
- login() – shows the login form
- authenticate() – handles login logic
- logout() – clears user session

πŸ“„ View
- Add views/login/index.view.php to render the login form

πŸ”€ Routing
- Register the necessary routes:
- GET /login β†’ shows the login form
- POST /login β†’ processes authentication
- POST /logout (or GET) β†’ logs the user out

🧠 Authentication Logic
- Inside authenticate():
- Validate email and password inputs
- Lookup user by email from the database
- Use password_verify() to check if password matches
- On success β†’ Session::login($user_id)
- On failure β†’ redirect back with error message

πŸ” Session Enhancements
- Add login($user_id) to store user ID in session
- Add logout() to destroy the session cleanly

πŸ“Œ And that lands us at v23-authentication.
Bob Cravens

Bob Cravens

Your Instructor
more »
Owner
TekFoundry
Wisconsin
United States
Short Bio:
Bob Cravens is a seasoned technology leader, software architect, and educator with a passion for empowering others through practical, real-world knowledge. As the founder of TekFoundry, Bob has dedicated his career to designing and delivering innovative software solutions that combine cutting-edge technology with elegant simplicity.

At TekCasts, Bob leverages over two decades of experience in software engineering, application architecture, and team leadership to create engaging, high-impact courses for developers and technology professionals. His instructional style is rooted in practical application, offering insights drawn from his extensive background in industries like medical devices and global technology consulting.

Bob’s expertise spans a variety of technologies and methodologies, including PHP/Laravel, FastAPI, and DevOps, as well as architecture best practices and team dynamics. Whether teaching foundational concepts or advanced strategies, he’s passionate about helping others turn complex challenges into streamlined solutions.

When not crafting elegant code or inspiring the next generation of tech innovators, Bob enjoys exploring the intersection of technology, business strategy, and creative problem-solving.