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.
Require authorization
From the course: PHP with MySQL Essential Training: 2 Build a CMS
Require authorization
- [Instructor] In the previous movie, we learned how to authenticate a user. That is how they can login with their username and their password. However, none of the pages that we have require that authorization right now, they all just let anyone view them, who wants to. What we need to do is add some code that will check to see whether the user is currently authenticated before it lets them have the page, to require that they have the authorization. To do this, I'm going to add a couple more functions to our off_functions.php that we added in the last movie. This code is included in the exercise files if you want to get it from there. I'm going to paste them in. The first function is, is_logged_in and is_logged_in is just going to check and see is the current user logged in. And the way it does that is it looks for that hand stamp, that ID that we put into the session, it checks to see if that value is set. If it exists, then we know the user is logged in, it's in their session. If…
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)
-
-