CodeIgniter From Scratch: Day 6videos

CodeIgniter From Scratch: Day 6 – Login

DiggThis

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

More Viewing Options

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.

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!


Screencast.com

…for providing the hosting for these video tutorials.


Related Posts

Add Comment

Discussion 211 Comments

Comment Page 4 of 4 1 2 3 4
  1. JK says:

    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

  2. Mike Randall says:

    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

  3. Nouman says:

    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

  4. Just ran through this tutorial at 3am in the morning. It was definitely worth it! :D

    Thank you again! ..and now for sleep.

  5. krike says:

    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

    • Kris says:

      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?

  6. Ko says:

    Bad video! Pls post a new link

  7. guy says:

    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!

  8. Diegop says:

    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

  9. Chris Men says:

    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 :)

  10. Jazzman says:

    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.

  11. DavidSwede says:

    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?

  12. rick says:

    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

  13. Alberto says:

    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!

Comment Page 4 of 4 1 2 3 4

Add a Comment