From the course: PHP with MySQL Essential Training: 2 Build a CMS
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Log out a user
From the course: PHP with MySQL Essential Training: 2 Build a CMS
Log out a user
- [Instructor] Now that we've learned how to authenticate a user and how to have pages that require that authorization, we need to learn how to remove the authorization or to log out a user. We already have a placeholder page for logging out, logout.php and we even have a link for it at the top of our page. But if we click that, it doesn't actually log us out. We stay logged in because it's not removing the hand stamp, that admin ID that we stored in the session, it's just unsetting session username, which was just a convenience that we had earlier. So what I'm going to do is I'm going to switch to auth_functions.php and right here below login admin, I'm going to add a new function called log out admin. This is also included the exercise files if you want to get it from there, and it's going to do the exact opposite of logging in the user, it's going to unset all of those session IDs, one for admin_id, last_login, and username. So it handles all the business of logging a user out. I…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
User authentication overview5m 11s
-
(Locked)
Create admins table3m 7s
-
(Locked)
Challenge: Build admin management3m 52s
-
(Locked)
Solution: Build admin management6m 30s
-
(Locked)
PHP password functions7m 27s
-
(Locked)
Authenticate user access8m 27s
-
(Locked)
Require authorization6m 15s
-
(Locked)
Log out a user2m 48s
-
(Locked)
Optional password updating6m 2s
-
(Locked)
Authorized previewing3m 46s
-
(Locked)
-
-