Advertisement
  1. Code
  2. PHP
  3. CodeIgniter

CodeIgniter From Scratch: Day 6 - Login

Scroll to top
Read Time: 1 min
This post is part of a series called CodeIgniter From Scratch.
CodeIgniter From Scratch: Day 5 - CRUD
CodeIgniter from Scratch Day 7: Pagination

In today's hour long video tutorial, we'll be doing a lot! We'll implement a login and signup form that will allow us to lock down certain sections of our fictional site. As you'll find, working with sessions in CodeIgniter is a cinch!

Catch Up

Day 6: Sessions

Login Form
Signup Form

P.S. The Logout Button

I forgot to add the "logout" button during the screencast. There was so much to cover, that I was bound to forget something! Luckily, it's really easy. Simply add a link, to the "members" area, which links to the login class, and a "logout" method (login/logout). Then, all we must do is destroy the user's session, and redirect them back to the login form. Download the source code if confused.

1
function logout()
2
{
3
	$this->session->sess_destroy();
4
	$this->index();
5
}

Hope you Enjoy it!

Keep in mind that we're just scratching the surface, in terms of flexibility and security. We can - and very well may - take things much further. But this should get you started!

Advertisement
Did you find this post useful?
Want a weekly email summary?
Subscribe below and we’ll send you a weekly email summary of all new Code tutorials. Never miss out on learning about the next big thing.
Advertisement
Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.