From the course: PHP: Object-Oriented Programming with Databases
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Add page access control - PHP Tutorial
From the course: PHP: Object-Oriented Programming with Databases
Add page access control
- [Instructor] Now that we have the ability for users to log in and log out and we're able to remember in our session whether or not they've logged in or not, we're able to now add access control to our pages. That is, that we can restrict the pages in our staff area to only allow logged in users to see them. The way we can do that is just simply to go to one of our staff area pages like index.php and right here at the top, we can just check to see. Put php tags and we'll just test to see if not dollar sign session is logged in. Then I'm going to redirect to url_for staff/login.php. And if they're not for some reason, then let's just do nothing, let the rest of the page proceed. So that's it, that's the process. It's going to check and see if the session says that the user is logged in. If they're not, then it will redirect them. If so, then they'll do nothing. Let's save it and try it out. Now at the…
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)
Admin class7m 40s
-
Hashing passwords7m
-
(Locked)
Admin validations7m 16s
-
(Locked)
Find by username5m 55s
-
(Locked)
Verify password5m 5s
-
(Locked)
Define a session class8m 34s
-
(Locked)
Add page access control4m 52s
-
(Locked)
Improve the session class7m 39s
-
(Locked)
Session messages6m 40s
-
(Locked)
-
-