Professional CodeIgniter, Thomas Myer

Chapter 6: Creating a Dashboard
159
Figure 6-3

When you ' re all done, upload your files and log in to the dashboard. You should see a home page that is
similar to what ' s pictured in Figure 6 - 3 .

It ' s certainly not flashy, but it ' s functional and clean. Of course, if you were to click on any of those links,
none of them would work, so it ' s time to start filling in the gaps in the system.

But before you do that, you will create a simple way to allow users to log out.


Creating a Logout Function

Creating a logout function is very easy. In this particular case, the logout links are pointed at admin/
dashboard/logout. All you need to do then is create a
logout()

function in your admin/dashboard
controller that destroys the CodeIgniter session and then redirects users back to the welcome/verify page.
function logout(){
unset($_SESSION[`userid']);
unset($_SESSION[`username']);
$this-
>
session-
>
set_flashdata(`error',"You've been logged out!");
redirect(`welcome/verify','refresh');
}
c06.indd 159
c06.indd 159
6/10/08 5:36:01 PM
6/10/08 5:36:01 PM


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.

OK

Loading...
...
Закрыть