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 1: Getting Started With the Framework
- Day 2: Database Selecting Methods
- Day 3: Sending Emails
- Day 4: Newsletter Signup
- Day 5: CRUD
Day 6: Sessions
More Viewing Options
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.
function logout()
{
$this->session->sess_destroy();
$this->index();
}
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!
Thank you, Screencast.com!
- Follow us on Twitter, or subscribe to the Nettuts+ RSS Feed for more daily web development tuts and articles.










Wonderful. That was a great tutorial, Jeff!
I loved how many things you covered and I didn’t mind the the video being longer than usual.
100 Kudos
Wonderful. That was a great tutorial, Jeff!
I loved how many things you covered and I didn’t mind the the video being longer than usual.
100 Kudos
Hey Jeff, question about the last 5 mins ( i had it until then X) )
when you are validating the user session, the link is too: (under login.php)
redirect(’site/members_area’);
However, isn’t going directly to members_area function on site.php skipping the
is_logged_in()
function? Which results in the view being loaded regardless.
When I set
redirect(’site/is_logged_in’); and add $this->members_area(); to the end of that function it works, but you can still visit the memebrs_area directly
still a little confused haha
I got it figured out
What was the problem?
Just ran through this tutorial at 3am in the morning. It was definitely worth it!
Thank you again! ..and now for sleep.
for all those who want to check if the username was allready taken or allready exist you can add your own form validation for unique values.
it’s the 3rd hack in that post which will help you check if the username was taken or not.
http://www.neurosoftware.ro/programming-blog/facebook-web-design/web-resources/6-codeigniter-hacks-for-the-masters/
I have tested this, it works perfectly and saves you a lot of trouble
That link redirected me to what seems to be a malware site without warning and would not let me back to the original page to view the info. I had to exit that browser window, disable javascript and then come back just to get to the page. XSS anyone?
Bad video! Pls post a new link
Thanks a lot Jeffrey!
I’ve just started a new project with CI and this tutorial has helped me so much. I now understand much more the basics in CI and I have deepen some of my knowledge in php.
Keep up the good work!
Excellent login screencast Jeffrey
Thanks so much
…Applause
This is one of the best tutorials I saw, please continue with more Sessions and CRUD of CI
It’s an amazing tutorial! Just a few questions:
If I wanna use this in a real project, what I have to change about security? I mean, what should I re-code to code and database be safety against hacking and protect data? Because codeigniter 1.7.2 doesn’t have any good auth and I wanna create mine, but I have some doubts about security.
Thank you for your help
I’m new to CodeIgniter, in fact, I’m not a programmer. I can echo a few things here and there, but I must say your tutorials are making a lot of sense to me.
I truly thank you for that brother.
Hi great tutorial! I’m doing an internship and these videotuts are a great help solving my assignment.
I’m having a slight problem thow…
When I hit the logout-link in the members_area-view I get redirected back to the login_view, as I should. But then: when I hit the backbutton in the browser I’m still able to acces the members_area. I’m wondering if anybody knows how to prevent this?
hey jeff,
can u make a tutorial with email confirmation?
i tried creating one but i always ended in ‘PAGE NOT FOUND’ error
thanks.. btw.. nice vid
Ey, If I go directly into /application/views/members_area.php I can see the page without being logged.
Is this a security issue or did I forget to include something?…
thks, keep up the good work!
Direct Link to the video:
Day 6: Login
http://a44.video2.blip.tv/5870002834299/NETTUTS-CodeIgniterFromScratchDay6219.flv
one more link
http://a-mirror.video2.blip.tv/NETTUTS-CodeIgniterFromScratchDay6219.mp4