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
In functions_auth.php we'll create a new function named isAuthenticated. This function will need to read our session to know if a user is logged in.
Verify isAuthenticated
File: templates/nav.php
<?php if (isAuthenticated()) : ?>
<li><a href="/add.php">Add Book</a></li>
<?php endif; ?>
<?php if (isAuthenticated()) : ?>
<li><a href="/procedures/doLogout.php">Logout</a></li>
<?php else: ?>
<li><a href="/login.php">Login</a></li>
<li><a href="/register.php">Register</a></li>
<?php endif; ?>
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
a New File named functions_auth.php.
0:00
We'll also need to add this
file to our bootstrap file.
0:02
Duplicate that line and we'll change
it to auth and then we can close it.
0:08
In our functions_auth file,
0:14
we're ready to create a new function.
0:18
We'll name this isAuthenticated.
0:22
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