1 00:00:00,650 --> 00:00:04,680 The final part of logging in is a log out system. 2 00:00:04,680 --> 00:00:09,180 We've already covered all of this, so it should not be anything new. 3 00:00:09,180 --> 00:00:11,800 We need to create a do log out procedure. 4 00:00:13,040 --> 00:00:15,175 Let's close up the ink folder. 5 00:00:17,171 --> 00:00:20,682 DoLogout.php. 6 00:00:26,194 --> 00:00:27,646 Require, 7 00:00:34,121 --> 00:00:39,909 Inc/bootstrap.php. 8 00:00:39,909 --> 00:00:44,170 Now, we're going to set the bad cookie and then redirect. 9 00:00:44,170 --> 00:00:47,136 Let's go to our function and copy these two lines. 10 00:00:53,437 --> 00:00:56,044 Now, let's change our navigation and 11 00:00:56,044 --> 00:00:59,289 check if the user should see the log in or log out. 12 00:01:06,437 --> 00:01:11,280 If not is authenticated, 13 00:01:15,128 --> 00:01:20,060 When we're breaking up our conditional statement over multiple code blocks, 14 00:01:20,060 --> 00:01:24,476 it can be easier to follow if we use a secondary format using a colon and, 15 00:01:24,476 --> 00:01:25,001 and if. 16 00:01:34,148 --> 00:01:37,424 We can also add an else for our log out link. 17 00:01:53,369 --> 00:01:56,494 Procedures/doLogout. 18 00:01:59,891 --> 00:02:05,086 Because we're using the is authenticated function in our navigation file, we'll 19 00:02:05,086 --> 00:02:10,075 need to add the bootstrap file to the rest of our login and register pages as well. 20 00:02:31,357 --> 00:02:33,900 We also need to clean up our home page. 21 00:02:38,067 --> 00:02:40,322 We'll move the bootstrap file to the top. 22 00:02:42,577 --> 00:02:45,120 And remove this extra logged in code. 23 00:02:49,798 --> 00:02:51,831 Let's take a look at this in the browser. 24 00:02:58,681 --> 00:03:01,530 While we're logged in, we see the link to log out. 25 00:03:02,660 --> 00:03:07,740 And when we log out, we see the links to log in or register again. 26 00:03:07,740 --> 00:03:12,690 Also, when we click on the Add Book, we get redirected to the log in page.