Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Introduction to User Authentication in PHP!
You have completed Introduction to User Authentication in PHP!
Preview
We need another function that we can use, on pages that require authentication. This requireAuth function will use our isAuthenticated function.
Requiring Authentication on Pages
Add requireAuth(); to the following files
- add.php
- procedures/addBook.php
- procedures/vote.php
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Let's create a new function and
we'll name this requireAuth.
0:00
This function will use our
isAuthenticated function.
0:07
If the user is not authenticated,
we will add a flash error message, and
0:12
redirect to login.
0:17
Don't forget to add the global session.
0:18
We'll set our session get flash bag,
0:25
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up